Make WordPress Core


Ignore:
Timestamp:
05/20/2022 05:36:23 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Replace phpversion() function calls with PHP_VERSION constant.

phpversion() return value and PHP_VERSION constant value are identical, but the latter is several times faster because it is a direct constant value lookup compared to a function call.

Props ayeshrajans, jrf, mukesh27, costdev, hellofromTonya, SergeyBiryukov.
Fixes #55680.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-automatic-updater.php

    r53131 r53426  
    223223                        global $wpdb;
    224224
    225                         $php_compat = version_compare( phpversion(), $item->php_version, '>=' );
     225                        $php_compat = version_compare( PHP_VERSION, $item->php_version, '>=' );
    226226                        if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
    227227                                $mysql_compat = true;
     
    237237                // If updating a plugin or theme, ensure the minimum PHP version requirements are satisfied.
    238238                if ( in_array( $type, array( 'plugin', 'theme' ), true ) ) {
    239                         if ( ! empty( $item->requires_php ) && version_compare( phpversion(), $item->requires_php, '<' ) ) {
     239                        if ( ! empty( $item->requires_php ) && version_compare( PHP_VERSION, $item->requires_php, '<' ) ) {
    240240                                return false;
    241241                        }
Note: See TracChangeset for help on using the changeset viewer.