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.


git-svn-id: https://develop.svn.wordpress.org/trunk@50586 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson
2021-03-26 00:07:26 +00:00
parent 7a4d7fc045
commit 42b05c397c

View File

@@ -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 );
}
}