Make WordPress Core


Ignore:
Timestamp:
09/03/2025 12:16:17 PM (6 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/IXR/class-IXR-message.php

    r60659 r60703  
    120120
    121121            if (!xml_parse($this->_parser, $part, $final)) {
    122                 xml_parser_free($this->_parser);
     122                if (PHP_VERSION_ID < 80000) { // xml_parser_free() has no effect as of PHP 8.0.
     123                    xml_parser_free($this->_parser);
     124                }
     125
    123126                unset($this->_parser);
    124127                return false;
     
    130133        } while (true);
    131134
    132         xml_parser_free($this->_parser);
     135        if (PHP_VERSION_ID < 80000) { // xml_parser_free() has no effect as of PHP 8.0.
     136            xml_parser_free($this->_parser);
     137        }
     138
    133139        unset($this->_parser);
    134140
Note: See TracChangeset for help on using the changeset viewer.