mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
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. Built from https://develop.svn.wordpress.org/trunk@53426 git-svn-id: http://core.svn.wordpress.org/trunk@53015 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
59c970101f
commit
40fc19024f
@ -266,7 +266,7 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
|||||||
$error = sprintf(
|
$error = sprintf(
|
||||||
/* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
|
/* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
|
||||||
__( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
|
__( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
|
||||||
phpversion(),
|
PHP_VERSION,
|
||||||
$requires_php
|
$requires_php
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||||||
$error = sprintf(
|
$error = sprintf(
|
||||||
/* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
|
/* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
|
||||||
__( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
|
__( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
|
||||||
phpversion(),
|
PHP_VERSION,
|
||||||
$requires_php
|
$requires_php
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
|||||||
$error = sprintf(
|
$error = sprintf(
|
||||||
/* translators: 1: Current PHP version, 2: Version required by the uploaded theme. */
|
/* translators: 1: Current PHP version, 2: Version required by the uploaded theme. */
|
||||||
__( 'The PHP version on your server is %1$s, however the uploaded theme requires %2$s.' ),
|
__( 'The PHP version on your server is %1$s, however the uploaded theme requires %2$s.' ),
|
||||||
phpversion(),
|
PHP_VERSION,
|
||||||
$requires_php
|
$requires_php
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||||||
$error = sprintf(
|
$error = sprintf(
|
||||||
/* translators: 1: Current PHP version, 2: Version required by the uploaded theme. */
|
/* translators: 1: Current PHP version, 2: Version required by the uploaded theme. */
|
||||||
__( 'The PHP version on your server is %1$s, however the uploaded theme requires %2$s.' ),
|
__( 'The PHP version on your server is %1$s, however the uploaded theme requires %2$s.' ),
|
||||||
phpversion(),
|
PHP_VERSION,
|
||||||
$requires_php
|
$requires_php
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ class WP_Automatic_Updater {
|
|||||||
if ( 'core' === $type ) {
|
if ( 'core' === $type ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$php_compat = version_compare( phpversion(), $item->php_version, '>=' );
|
$php_compat = version_compare( PHP_VERSION, $item->php_version, '>=' );
|
||||||
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
|
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
|
||||||
$mysql_compat = true;
|
$mysql_compat = true;
|
||||||
} else {
|
} else {
|
||||||
@ -236,7 +236,7 @@ class WP_Automatic_Updater {
|
|||||||
|
|
||||||
// If updating a plugin or theme, ensure the minimum PHP version requirements are satisfied.
|
// If updating a plugin or theme, ensure the minimum PHP version requirements are satisfied.
|
||||||
if ( in_array( $type, array( 'plugin', 'theme' ), true ) ) {
|
if ( in_array( $type, array( 'plugin', 'theme' ), true ) ) {
|
||||||
if ( ! empty( $item->requires_php ) && version_compare( phpversion(), $item->requires_php, '<' ) ) {
|
if ( ! empty( $item->requires_php ) && version_compare( PHP_VERSION, $item->requires_php, '<' ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -677,23 +677,18 @@ class WP_Debug_Data {
|
|||||||
$server_architecture = 'unknown';
|
$server_architecture = 'unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( function_exists( 'phpversion' ) ) {
|
$php_version_debug = PHP_VERSION;
|
||||||
$php_version_debug = phpversion();
|
// Whether PHP supports 64-bit.
|
||||||
// Whether PHP supports 64-bit.
|
$php64bit = ( PHP_INT_SIZE * 8 === 64 );
|
||||||
$php64bit = ( PHP_INT_SIZE * 8 === 64 );
|
|
||||||
|
|
||||||
$php_version = sprintf(
|
$php_version = sprintf(
|
||||||
'%s %s',
|
'%s %s',
|
||||||
$php_version_debug,
|
$php_version_debug,
|
||||||
( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) )
|
( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) )
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $php64bit ) {
|
if ( $php64bit ) {
|
||||||
$php_version_debug .= ' 64bit';
|
$php_version_debug .= ' 64bit';
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$php_version = __( 'Unable to determine PHP version' );
|
|
||||||
$php_version_debug = 'unknown';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( function_exists( 'php_sapi_name' ) ) {
|
if ( function_exists( 'php_sapi_name' ) ) {
|
||||||
|
@ -1385,7 +1385,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
|
|||||||
'<span class="code">' . esc_html( $filename_for_errors ) . '</span>'
|
'<span class="code">' . esc_html( $filename_for_errors ) . '</span>'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'php' => phpversion(),
|
'php' => PHP_VERSION,
|
||||||
'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
|
'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -1420,7 +1420,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
|
|||||||
'<span class="code">' . esc_html( $filename_for_errors ) . '</span>'
|
'<span class="code">' . esc_html( $filename_for_errors ) . '</span>'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'php' => phpversion(),
|
'php' => PHP_VERSION,
|
||||||
'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
|
'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
|
||||||
'polyfill_is_fast' => false,
|
'polyfill_is_fast' => false,
|
||||||
'max_execution_time' => ini_get( 'max_execution_time' ),
|
'max_execution_time' => ini_get( 'max_execution_time' ),
|
||||||
@ -1493,7 +1493,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
|
|||||||
'hash' => bin2hex( $file_hash ),
|
'hash' => bin2hex( $file_hash ),
|
||||||
'skipped_key' => $skipped_key,
|
'skipped_key' => $skipped_key,
|
||||||
'skipped_sig' => $skipped_signature,
|
'skipped_sig' => $skipped_signature,
|
||||||
'php' => phpversion(),
|
'php' => PHP_VERSION,
|
||||||
'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
|
'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -1524,7 +1524,7 @@ function _wp_privacy_settings_filter_draft_page_titles( $title, $page ) {
|
|||||||
* @return array|false Array of PHP version data. False on failure.
|
* @return array|false Array of PHP version data. False on failure.
|
||||||
*/
|
*/
|
||||||
function wp_check_php_version() {
|
function wp_check_php_version() {
|
||||||
$version = phpversion();
|
$version = PHP_VERSION;
|
||||||
$key = md5( $version );
|
$key = md5( $version );
|
||||||
|
|
||||||
$response = get_site_transient( 'php_check_' . $key );
|
$response = get_site_transient( 'php_check_' . $key );
|
||||||
|
@ -1150,7 +1150,7 @@ function validate_plugin_requirements( $plugin ) {
|
|||||||
/* translators: 1: Current WordPress version, 2: Current PHP version, 3: Plugin name, 4: Required WordPress version, 5: Required PHP version. */
|
/* translators: 1: Current WordPress version, 2: Current PHP version, 3: Plugin name, 4: Required WordPress version, 5: Required PHP version. */
|
||||||
_x( '<strong>Error:</strong> Current versions of WordPress (%1$s) and PHP (%2$s) do not meet minimum requirements for %3$s. The plugin requires WordPress %4$s and PHP %5$s.', 'plugin' ),
|
_x( '<strong>Error:</strong> Current versions of WordPress (%1$s) and PHP (%2$s) do not meet minimum requirements for %3$s. The plugin requires WordPress %4$s and PHP %5$s.', 'plugin' ),
|
||||||
get_bloginfo( 'version' ),
|
get_bloginfo( 'version' ),
|
||||||
phpversion(),
|
PHP_VERSION,
|
||||||
$plugin_headers['Name'],
|
$plugin_headers['Name'],
|
||||||
$requirements['requires'],
|
$requirements['requires'],
|
||||||
$requirements['requires_php']
|
$requirements['requires_php']
|
||||||
@ -1162,7 +1162,7 @@ function validate_plugin_requirements( $plugin ) {
|
|||||||
'<p>' . sprintf(
|
'<p>' . sprintf(
|
||||||
/* translators: 1: Current PHP version, 2: Plugin name, 3: Required PHP version. */
|
/* translators: 1: Current PHP version, 2: Plugin name, 3: Required PHP version. */
|
||||||
_x( '<strong>Error:</strong> Current PHP version (%1$s) does not meet minimum requirements for %2$s. The plugin requires PHP %3$s.', 'plugin' ),
|
_x( '<strong>Error:</strong> Current PHP version (%1$s) does not meet minimum requirements for %2$s. The plugin requires PHP %3$s.', 'plugin' ),
|
||||||
phpversion(),
|
PHP_VERSION,
|
||||||
$plugin_headers['Name'],
|
$plugin_headers['Name'],
|
||||||
$requirements['requires_php']
|
$requirements['requires_php']
|
||||||
) . $php_update_message . '</p>'
|
) . $php_update_message . '</p>'
|
||||||
|
@ -1012,7 +1012,7 @@ function update_core( $from, $to ) {
|
|||||||
require WP_CONTENT_DIR . '/upgrade/version-current.php';
|
require WP_CONTENT_DIR . '/upgrade/version-current.php';
|
||||||
$wp_filesystem->delete( $versions_file );
|
$wp_filesystem->delete( $versions_file );
|
||||||
|
|
||||||
$php_version = phpversion();
|
$php_version = PHP_VERSION;
|
||||||
$mysql_version = $wpdb->db_version();
|
$mysql_version = $wpdb->db_version();
|
||||||
$old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from.
|
$old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from.
|
||||||
$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // A dash in the version indicates a development release.
|
$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // A dash in the version indicates a development release.
|
||||||
|
@ -228,7 +228,7 @@ if ( is_blog_installed() ) {
|
|||||||
*/
|
*/
|
||||||
global $wp_version, $required_php_version, $required_mysql_version;
|
global $wp_version, $required_php_version, $required_mysql_version;
|
||||||
|
|
||||||
$php_version = phpversion();
|
$php_version = PHP_VERSION;
|
||||||
$mysql_version = $wpdb->db_version();
|
$mysql_version = $wpdb->db_version();
|
||||||
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
|
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
|
||||||
$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
|
$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
|
||||||
|
@ -59,7 +59,7 @@ function list_core_update( $update ) {
|
|||||||
|
|
||||||
$message = '';
|
$message = '';
|
||||||
$form_action = 'update-core.php?action=do-core-upgrade';
|
$form_action = 'update-core.php?action=do-core-upgrade';
|
||||||
$php_version = phpversion();
|
$php_version = PHP_VERSION;
|
||||||
$mysql_version = $wpdb->db_version();
|
$mysql_version = $wpdb->db_version();
|
||||||
$show_buttons = true;
|
$show_buttons = true;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ global $wp_version, $required_php_version, $required_mysql_version;
|
|||||||
|
|
||||||
$step = (int) $step;
|
$step = (int) $step;
|
||||||
|
|
||||||
$php_version = phpversion();
|
$php_version = PHP_VERSION;
|
||||||
$mysql_version = $wpdb->db_version();
|
$mysql_version = $wpdb->db_version();
|
||||||
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
|
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
|
||||||
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
|
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
ignore_user_abort( true );
|
ignore_user_abort( true );
|
||||||
|
|
||||||
/* Don't make the request block till we finish, if possible. */
|
/* Don't make the request block till we finish, if possible. */
|
||||||
if ( function_exists( 'fastcgi_finish_request' ) && version_compare( phpversion(), '7.0.16', '>=' ) ) {
|
if ( PHP_VERSION_ID >= 70016 && function_exists( 'fastcgi_finish_request' ) ) {
|
||||||
if ( ! headers_sent() ) {
|
if ( ! headers_sent() ) {
|
||||||
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
|
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
|
||||||
header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
|
header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
|
||||||
|
@ -8422,7 +8422,7 @@ function is_wp_version_compatible( $required ) {
|
|||||||
* @return bool True if required version is compatible or empty, false if not.
|
* @return bool True if required version is compatible or empty, false if not.
|
||||||
*/
|
*/
|
||||||
function is_php_version_compatible( $required ) {
|
function is_php_version_compatible( $required ) {
|
||||||
return empty( $required ) || version_compare( phpversion(), $required, '>=' );
|
return empty( $required ) || version_compare( PHP_VERSION, $required, '>=' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,7 +143,7 @@ function wp_populate_basic_auth_from_authorization_header() {
|
|||||||
*/
|
*/
|
||||||
function wp_check_php_mysql_versions() {
|
function wp_check_php_mysql_versions() {
|
||||||
global $required_php_version, $wp_version;
|
global $required_php_version, $wp_version;
|
||||||
$php_version = phpversion();
|
$php_version = PHP_VERSION;
|
||||||
|
|
||||||
if ( version_compare( $required_php_version, $php_version, '>' ) ) {
|
if ( version_compare( $required_php_version, $php_version, '>' ) ) {
|
||||||
$protocol = wp_get_server_protocol();
|
$protocol = wp_get_server_protocol();
|
||||||
|
@ -32,7 +32,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
|
|||||||
|
|
||||||
// Include an unmodified $wp_version.
|
// Include an unmodified $wp_version.
|
||||||
require ABSPATH . WPINC . '/version.php';
|
require ABSPATH . WPINC . '/version.php';
|
||||||
$php_version = phpversion();
|
$php_version = PHP_VERSION;
|
||||||
|
|
||||||
$current = get_site_transient( 'update_core' );
|
$current = get_site_transient( 'update_core' );
|
||||||
$translations = wp_get_installed_translations( 'core' );
|
$translations = wp_get_installed_translations( 'core' );
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.1-alpha-53421';
|
$wp_version = '6.1-alpha-53426';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user