Make WordPress Core

Changeset 50586 for trunk


Ignore:
Timestamp:
03/26/2021 12:07:26 AM (5 years ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r50560 r50586  
    49884988                defined( 'WP_DEBUG' ) && WP_DEBUG
    49894989        ) {
    4990                 return getimagesize( $filename, $image_info );
     4990                if ( 2 === func_num_args() ) {
     4991                        return getimagesize( $filename, $image_info );
     4992                } else {
     4993                        return getimagesize( $filename );
     4994                }
    49914995        }
    49924996
     
    49995003         *
    50005004         * See https://core.trac.wordpress.org/ticket/42480
    5001          *
    5002          * phpcs:ignore WordPress.PHP.NoSilencedErrors
    5003          */
    5004         return @getimagesize( $filename, $image_info );
    5005 }
     5005         */
     5006        if ( 2 === func_num_args() ) {
     5007                // phpcs:ignore WordPress.PHP.NoSilencedErrors
     5008                return @getimagesize( $filename, $image_info );
     5009        } else {
     5010                // phpcs:ignore WordPress.PHP.NoSilencedErrors
     5011                return @getimagesize( $filename );
     5012        }
     5013}
Note: See TracChangeset for help on using the changeset viewer.