Make WordPress Core


Ignore:
Timestamp:
12/04/2020 09:44:27 PM (3 years ago)
Author:
iandunn
Message:

Media: Return WP_Error when cropping with bad input to avoid fatal.

This avoids an error on PHP 8 caused by calling wp_imagecreatetruecolor() with inputs that aren't numeric, or are less than 0.

Props hellofromtonya, Boniu91, metalandcoffee, SergeyBiryukov.
Reviewed by SergeyBiryukov, iandunn.
Merges [49751] to the 5.6 branch.
Fixes #51937.

Location:
branches/5.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

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

    r49613 r49753  
    35063506 * @param int $width  Image width in pixels.
    35073507 * @param int $height Image height in pixels.
    3508  * @return resource|GdImage The GD image resource or GdImage instance.
     3508 * @return resource|GdImage|false The GD image resource or GdImage instance on success. False on failure.
    35093509 */
    35103510function wp_imagecreatetruecolor( $width, $height ) {
Note: See TracChangeset for help on using the changeset viewer.