Make WordPress Core

Ticket #49889: 49889.4.diff

File 49889.4.diff, 7.8 KB (added by SergeyBiryukov, 5 years ago)
  • src/wp-admin/includes/ajax-actions.php

     
    39273927                        $parent_url = wp_get_attachment_url( $attachment_id );
    39283928                        $url        = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
    39293929
    3930                         $size       = @getimagesize( $cropped );
     3930                        $size       = wp_getimagesize( $cropped );
    39313931                        $image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
    39323932
    39333933                        $object = array(
  • src/wp-admin/includes/class-custom-image-header.php

     
    791791                }
    792792
    793793                if ( file_exists( $file ) ) {
    794                         list( $width, $height, $type, $attr ) = @getimagesize( $file );
     794                        list( $width, $height, $type, $attr ) = wp_getimagesize( $file );
    795795                } else {
    796796                        $data   = wp_get_attachment_metadata( $attachment_id );
    797797                        $height = isset( $data['height'] ) ? $data['height'] : 0;
     
    12231223                $parent_url = wp_get_attachment_url( $parent->ID );
    12241224                $url        = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
    12251225
    1226                 $size       = @getimagesize( $cropped );
     1226                $size       = wp_getimagesize( $cropped );
    12271227                $image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
    12281228
    12291229                $object = array(
  • src/wp-admin/includes/class-wp-site-icon.php

     
    8787                $parent_url = wp_get_attachment_url( $parent->ID );
    8888                $url        = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
    8989
    90                 $size       = @getimagesize( $cropped );
     90                $size       = wp_getimagesize( $cropped );
    9191                $image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
    9292
    9393                $object = array(
  • src/wp-admin/includes/image.php

     
    9393        // Use the originally uploaded image dimensions as full_width and full_height.
    9494        if ( ! empty( $image_meta['original_image'] ) ) {
    9595                $image_file = wp_get_original_image_path( $attachment_id );
    96                 $imagesize  = @getimagesize( $image_file );
     96                $imagesize  = wp_getimagesize( $image_file );
    9797        }
    9898
    9999        if ( ! empty( $imagesize ) ) {
     
    224224 * @return array The image attachment meta data.
    225225 */
    226226function wp_create_image_subsizes( $file, $attachment_id ) {
    227         $imagesize = @getimagesize( $file );
     227        $imagesize = wp_getimagesize( $file );
    228228
    229229        if ( empty( $imagesize ) ) {
    230230                // File is not an image.
     
    687687                return false;
    688688        }
    689689
    690         list( , , $image_type ) = @getimagesize( $file );
     690        list( , , $image_type ) = wp_getimagesize( $file );
    691691
    692692        /*
    693693         * EXIF contains a bunch of data we'll probably never need formatted in ways
     
    716716         * as caption, description etc.
    717717         */
    718718        if ( is_callable( 'iptcparse' ) ) {
    719                 @getimagesize( $file, $info );
     719                wp_getimagesize( $file, $info );
    720720
    721721                if ( ! empty( $info['APP13'] ) ) {
    722                         $iptc = @iptcparse( $info['APP13'] );
     722                        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     723                                $iptc = iptcparse( $info['APP13'] );
     724                        } else {
     725                                $iptc = @iptcparse( $info['APP13'] );
     726                        }
    723727
    724728                        // Headline, "A brief synopsis of the caption".
    725729                        if ( ! empty( $iptc['2#105'][0] ) ) {
     
    779783        $exif_image_types = apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) );
    780784
    781785        if ( is_callable( 'exif_read_data' ) && in_array( $image_type, $exif_image_types, true ) ) {
    782                 $exif = @exif_read_data( $file );
     786                if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     787                        $exif = exif_read_data( $file );
     788                } else {
     789                        $exif = @exif_read_data( $file );
     790                }
    783791
    784792                if ( ! empty( $exif['ImageDescription'] ) ) {
    785793                        mbstring_binary_safe_encoding();
     
    877885 * @return bool True if valid image, false if not valid image.
    878886 */
    879887function file_is_valid_image( $path ) {
    880         $size = @getimagesize( $path );
     888        $size = wp_getimagesize( $path );
    881889        return ! empty( $size );
    882890}
    883891
     
    892900function file_is_displayable_image( $path ) {
    893901        $displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_ICO );
    894902
    895         $info = @getimagesize( $path );
     903        $info = wp_getimagesize( $path );
    896904        if ( empty( $info ) ) {
    897905                $result = false;
    898906        } elseif ( ! in_array( $info[2], $displayable_image_types, true ) ) {
  • src/wp-includes/class-wp-image-editor-gd.php

     
    105105                        return new WP_Error( 'invalid_image', __( 'File is not an image.' ), $this->file );
    106106                }
    107107
    108                 $size = @getimagesize( $this->file );
     108                $size = wp_getimagesize( $this->file );
    109109
    110110                if ( ! $size ) {
    111111                        return new WP_Error( 'invalid_image', __( 'Could not read image size.' ), $this->file );
  • src/wp-includes/deprecated.php

     
    19471947        // Do we need to constrain the image?
    19481948        if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
    19491949
    1950                 $imagesize = @getimagesize($src_file);
     1950                $imagesize = wp_getimagesize($src_file);
    19511951
    19521952                if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
    19531953                        $actual_aspect = $imagesize[0] / $imagesize[1];
  • src/wp-includes/functions.php

     
    30443044                        $imagetype = exif_imagetype( $file );
    30453045                        $mime      = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false;
    30463046                } elseif ( function_exists( 'getimagesize' ) ) {
    3047                         $imagesize = @getimagesize( $file );
     3047                        $imagesize = wp_getimagesize( $file );
    30483048                        $mime      = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
    30493049                } else {
    30503050                        $mime = false;
     
    77677767function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) {
    77687768        return abs( (float) $expected - (float) $actual ) <= $precision;
    77697769}
     7770
     7771/**
     7772 * Allows PHP's getimagesize() to be debuggable when necessary.
     7773 *
     7774 * @since 5.6.0
     7775 *
     7776 * @param string $filename The file path.
     7777 * @param array $imageinfo Extended image information, passed by reference.
     7778 * @return array|false Array of image information or false on failure.
     7779 */
     7780function wp_getimagesize( $filename, &$imageinfo = array() ) {
     7781        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     7782                return getimagesize( $filename, $imageinfo );
     7783        }
     7784
     7785        return @getimagesize( $filename, $imageinfo );
     7786}
  • src/wp-includes/media.php

     
    244244                $info       = null;
    245245
    246246                if ( $thumb_file ) {
    247                         $info = @getimagesize( $thumb_file );
     247                        $info = wp_getimagesize( $thumb_file );
    248248                }
    249249
    250250                if ( $thumb_file && $info ) {
     
    962962                                $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );
    963963
    964964                                $src_file               = $icon_dir . '/' . wp_basename( $src );
    965                                 list( $width, $height ) = @getimagesize( $src_file );
     965                                list( $width, $height ) = wp_getimagesize( $src_file );
    966966                        }
    967967                }
    968968