Make WordPress Core

Changeset 53303


Ignore:
Timestamp:
04/28/2022 10:58:48 AM (3 years ago)
Author:
mikeschroder
Message:

Media: Ensure wp_read_image_metadata filter returns array for $iptc and $exif.

Makes the behavior of the filter lines up with its documentation.
Previously, both $iptc and $exif could return false when exif_read_data() or iptcparse() failed.

Now, if those functions do not return an array, the results are explicitly set to array().

Props volodymyrkolesnykov, SergeyBiryukov, sabernhardt, sumitsingh, mikeschroder.
Fixes #54637.

File:
1 edited

Legend:

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

    r53292 r53303  
    777777            }
    778778
     779            if ( ! is_array( $iptc ) ) {
     780                $iptc = array();
     781            }
     782
    779783            // Headline, "A brief synopsis of the caption".
    780784            if ( ! empty( $iptc['2#105'][0] ) ) {
     
    844848            // phpcs:ignore WordPress.PHP.NoSilencedErrors -- Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
    845849            $exif = @exif_read_data( $file );
     850        }
     851
     852        if ( ! is_array( $exif ) ) {
     853            $exif = array();
    846854        }
    847855
Note: See TracChangeset for help on using the changeset viewer.