Make WordPress Core


Ignore:
Timestamp:
09/03/2025 12:16:17 PM (14 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-includes/functions.php

    r60696 r60703  
    31733173                $finfo     = finfo_open( FILEINFO_MIME_TYPE );
    31743174                $real_mime = finfo_file( $finfo, $file );
    3175                 finfo_close( $finfo );
     3175
     3176                if ( PHP_VERSION_ID < 80100 ) { // finfo_close() has no effect as of PHP 8.1.
     3177                        finfo_close( $finfo );
     3178                }
    31763179
    31773180                $google_docs_types = array(
    … …  
    34023405                                        $fileinfo  = finfo_open( FILEINFO_MIME_TYPE );
    34033406                                        $mime_type = finfo_file( $fileinfo, $file );
    3404                                         finfo_close( $fileinfo );
     3407
     3408                                        if ( PHP_VERSION_ID < 80100 ) { // finfo_close() has no effect as of PHP 8.1.
     3409                                                finfo_close( $fileinfo );
     3410                                        }
    34053411
    34063412                                        if ( wp_is_heic_image_mime_type( $mime_type ) ) {
Note: See TracChangeset for help on using the changeset viewer.