Make WordPress Core

Changeset 50662


Ignore:
Timestamp:
04/06/2021 03:42:02 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.
Merges [50586] to the 5.7 branch.
Fixes #52826.

Location:
branches/5.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.7

  • branches/5.7/src/wp-includes/media.php

    r50553 r50662  
    49834983                defined( 'WP_DEBUG' ) && WP_DEBUG
    49844984        ) {
    4985                 return getimagesize( $filename, $image_info );
     4985                if ( 2 === func_num_args() ) {
     4986                        return getimagesize( $filename, $image_info );
     4987                } else {
     4988                        return getimagesize( $filename );
     4989                }
    49864990        }
    49874991
     
    49944998         *
    49954999         * See https://core.trac.wordpress.org/ticket/42480
    4996          *
    4997          * phpcs:ignore WordPress.PHP.NoSilencedErrors
    4998          */
    4999         return @getimagesize( $filename, $image_info );
    5000 }
     5000         */
     5001        if ( 2 === func_num_args() ) {
     5002                // phpcs:ignore WordPress.PHP.NoSilencedErrors
     5003                return @getimagesize( $filename, $image_info );
     5004        } else {
     5005                // phpcs:ignore WordPress.PHP.NoSilencedErrors
     5006                return @getimagesize( $filename );
     5007        }
     5008}
Note: See TracChangeset for help on using the changeset viewer.