From cc7bdc71e8d4aad391cb5af7a40f2d23470462e7 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Fri, 26 Mar 2021 00:09:04 +0000 Subject: [PATCH] Media: Conditionally pass 2nd parameter to `getimagesize()`. In the wrapper function `wp_getimagesize()` check if the second parameter was passed before sending it to the PHP function `getimagesize()`. The PHP function has a different execution path depending on the number of parameters passed, this ensures the wrapper function follows the appropriate path. Follow up to [50552]. Props azaozz, hellofromtonya, Mista-Flo, peterwilsoncc, rinatkhaziev, RogerTheriault, SergeyBiryukov, terriann, whyisjake. Fixes #52826. Built from https://develop.svn.wordpress.org/trunk@50586 git-svn-id: http://core.svn.wordpress.org/trunk@50199 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 16 ++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 86e8ac221f..89b972603b 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -4987,7 +4987,11 @@ function wp_getimagesize( $filename, array &$image_info = null ) { // Return without silencing errors when in debug mode. defined( 'WP_DEBUG' ) && WP_DEBUG ) { - return getimagesize( $filename, $image_info ); + if ( 2 === func_num_args() ) { + return getimagesize( $filename, $image_info ); + } else { + return getimagesize( $filename ); + } } /* @@ -4998,8 +5002,12 @@ function wp_getimagesize( $filename, array &$image_info = null ) { * even when it's able to provide image size information. * * See https://core.trac.wordpress.org/ticket/42480 - * - * phpcs:ignore WordPress.PHP.NoSilencedErrors */ - return @getimagesize( $filename, $image_info ); + if ( 2 === func_num_args() ) { + // phpcs:ignore WordPress.PHP.NoSilencedErrors + return @getimagesize( $filename, $image_info ); + } else { + // phpcs:ignore WordPress.PHP.NoSilencedErrors + return @getimagesize( $filename ); + } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 5aa8a0d3a4..503a0b0100 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-50585'; +$wp_version = '5.8-alpha-50586'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.