From 3d1220d2ea02cf180fa57a11091e0e5ef5a7909c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Thu, 4 Apr 2024 14:13:40 -0400 Subject: [PATCH 1/2] update return hint --- classes/Optimization/File.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/classes/Optimization/File.php b/classes/Optimization/File.php index 6173b204..7c2fb181 100644 --- a/classes/Optimization/File.php +++ b/classes/Optimization/File.php @@ -745,10 +745,9 @@ public function get_mime_type() { /** * Get the file extension. * - * @since 1.9 - * @author Grégory Viguier + * @since 1.9 * - * @return string|null + * @return string|false */ public function get_extension() { return $this->get_file_type()->ext; From 137b87dd88b1c30de42180d149703616f653dff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Thu, 4 Apr 2024 14:13:50 -0400 Subject: [PATCH 2/2] add condition to handle false value --- classes/Optimization/Process/AbstractProcess.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/classes/Optimization/Process/AbstractProcess.php b/classes/Optimization/Process/AbstractProcess.php index bc1868aa..afef4c47 100644 --- a/classes/Optimization/Process/AbstractProcess.php +++ b/classes/Optimization/Process/AbstractProcess.php @@ -581,7 +581,12 @@ public function optimize_size( $size, $optimization_level = null ) { // This file type is not supported. $extension = $file->get_extension(); - if ( '' === $extension ) { + if ( ! $extension ) { + $response = new WP_Error( + 'extension_not_mime', + __( 'This file has an extension that does not match a mime type.', 'imagify' ) + ); + } elseif ( '' === $extension ) { $response = new WP_Error( 'no_extension', __( 'With no extension, this file cannot be optimized.', 'imagify' )