From 67dfa8d0193617035d73655c19988d8d12ed87e4 Mon Sep 17 00:00:00 2001 From: Khokan Sardar Date: Tue, 4 Aug 2026 09:48:35 +0530 Subject: [PATCH] Media: Assign the HEIC upload error flag to the Plupload settings. `wp_show_heic_upload_error()` assigned `heic_upload_error` to an undeclared `$plupload_init` variable instead of the `$plupload_settings` parameter it receives, so the callback returned the settings unchanged and the flag was never added. The `plupload_default_settings` path was unaffected in practice, as `wp_plupload_default_settings()` already sets the flag inline. The `plupload_init` path, used by `media_upload_form()` on media-new.php and in the media-upload.php iframe, sets the WebP and AVIF flags inline but relies on this callback for HEIC, so no error was shown there when the server could not edit HEIC images. Assign to the parameter, and add a regression test. Follow-up to [58849]. Fixes #65802. --- src/wp-includes/media.php | 2 +- .../tests/media/wpShowHeicUploadError.php | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/tests/media/wpShowHeicUploadError.php diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index a31e77b00e26c..c6c6a2cefeb6c 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -5879,7 +5879,7 @@ function _wp_add_additional_image_sizes() { function wp_show_heic_upload_error( $plupload_settings ) { // Check if HEIC images can be edited. if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/heic' ) ) ) { - $plupload_init['heic_upload_error'] = true; + $plupload_settings['heic_upload_error'] = true; } return $plupload_settings; } diff --git a/tests/phpunit/tests/media/wpShowHeicUploadError.php b/tests/phpunit/tests/media/wpShowHeicUploadError.php new file mode 100644 index 0000000000000..468a636e2cd07 --- /dev/null +++ b/tests/phpunit/tests/media/wpShowHeicUploadError.php @@ -0,0 +1,25 @@ +assertSame( + array( + 'existing' => 'value', + 'heic_upload_error' => true, + ), + wp_show_heic_upload_error( array( 'existing' => 'value' ) ) + ); + } +}