From 7398473d3330322f19d366aa32c750be2c6f4fff Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 19 Mar 2021 02:11:23 +0000 Subject: [PATCH] Media: Pass the appropriate reference into `wp_getimagesize`. With changes that were introduced in #49889 the second parameter for getimagesize() function is expecting a a reference. Previously, most calls did not pass the 2nd param, and as a result, we are getting unexpected results. This was only a problem with applications that are using a custom stream wrapper, and the image contained EXIF data. For more see: https://github.com/humanmade/S3-Uploads/issues/496 https://github.com/aws/aws-sdk-php/issues/1923 Fixes #52826. Merges [50552] to the 5.7 branch. Props terriann, SergeyBiryukov, Mista-Flo, hellofromTonya, rinatkhaziev, whyisjake. git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50553 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/image.php | 1 + src/wp-includes/media.php | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/includes/image.php b/src/wp-admin/includes/image.php index 56b9c0a36f..673c1dff01 100644 --- a/src/wp-admin/includes/image.php +++ b/src/wp-admin/includes/image.php @@ -711,6 +711,7 @@ function wp_read_image_metadata( $file ) { ); $iptc = array(); + $info = array(); /* * Read IPTC first, since it might contain data not available in exif such * as caption, description etc. diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 349bcbae1d..8825551fef 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -4970,11 +4970,11 @@ function wp_show_heic_upload_error( $plupload_settings ) { * * @since 5.7.0 * - * @param string $filename The file path. - * @param array $imageinfo Extended image information, passed by reference. + * @param string $filename The file path. + * @param array $image_info Optional. Extended image information (passed by reference). * @return array|false Array of image information or false on failure. */ -function wp_getimagesize( $filename, &$imageinfo = array() ) { +function wp_getimagesize( $filename, array &$image_info = null ) { if ( // Skip when running unit tests. ! defined( 'WP_RUN_CORE_TESTS' ) @@ -4982,7 +4982,7 @@ function wp_getimagesize( $filename, &$imageinfo = array() ) { // Return without silencing errors when in debug mode. defined( 'WP_DEBUG' ) && WP_DEBUG ) { - return getimagesize( $filename, $imageinfo ); + return getimagesize( $filename, $image_info ); } /* @@ -4996,5 +4996,5 @@ function wp_getimagesize( $filename, &$imageinfo = array() ) { * * phpcs:ignore WordPress.PHP.NoSilencedErrors */ - return @getimagesize( $filename, $imageinfo ); + return @getimagesize( $filename, $image_info ); }