Make WordPress Core


Ignore:
Timestamp:
09/03/2025 12:16:17 PM (3 months ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Address no-op function deprecations in PHP 8.5.

Several PHP functions that have not been doing anything since PHP 8.0/8.1, specifically:

  • finfo_close() since the ext/fileinfo migration in PHP 8.1
  • xml_parser_free() since the ext/xml migration in PHP 8.0
  • curl_close() since the ext/curl migration in PHP 8.0
  • curl_share_close() since the ext/curl migration in PHP 8.0
  • imagedestroy() since the ext/gd migration in PHP 8.0

will be deprecated in PHP 8.5 and will thus be throwing warnings.

This commit adds conditional checks to only call these functions on the relevant PHP versions.

Reference: PHP RFC: Deprecations for PHP 8.5: Deprecate no-op functions from the resource to object conversion.

Props TobiasBg, SergeyBiryukov.
See #63061.

File:
1 edited

Legend:

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

    r60640 r60703  
    546546
    547547        if ( is_gd_image( $rotated ) ) {
    548             imagedestroy( $img );
     548            if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0.
     549                imagedestroy( $img );
     550            }
     551
    549552            $img = $rotated;
    550553        }
     
    581584
    582585        if ( imagecopyresampled( $dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh ) ) {
    583             imagedestroy( $img );
     586            if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0.
     587                imagedestroy( $img );
     588            }
     589
    584590            $img = $dst;
    585591        }
     
    607613    if ( is_gd_image( $dst ) ) {
    608614        if ( imagecopy( $dst, $img, 0, 0, $x, $y, $w, $h ) ) {
    609             imagedestroy( $img );
     615            if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0.
     616                imagedestroy( $img );
     617            }
     618
    610619            $img = $dst;
    611620        }
Note: See TracChangeset for help on using the changeset viewer.