Bootstrap/Load: Reorganize the initialization flow so that the check for PHP and MySQL requirements could run as early as possible.

This allows us to use PHP 5.6+ syntax in more files, and display a proper error message on older PHP versions, instead of causing a parse error.

Fixes #48059.
Built from https://develop.svn.wordpress.org/trunk@46183


git-svn-id: http://core.svn.wordpress.org/trunk@45995 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-09-19 12:02:58 +00:00
parent 06b4278933
commit 7c9d4950b7
3 changed files with 14 additions and 17 deletions

View File

@ -131,13 +131,10 @@ function wp_check_php_mysql_versions() {
$php_version = phpversion();
if ( version_compare( $required_php_version, $php_version, '>' ) ) {
wp_load_translations_early();
$protocol = wp_get_server_protocol();
header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
header( 'Content-Type: text/html; charset=utf-8' );
/* translators: 1: Current PHP version number, 2: WordPress version number, 3: Minimum required PHP version number. */
printf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version );
printf( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.', $php_version, $wp_version, $required_php_version );
exit( 1 );
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.3-alpha-46182';
$wp_version = '5.3-alpha-46183';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -15,8 +15,19 @@
*/
define( 'WPINC', 'wp-includes' );
// Include files required for initialization.
/*
* These can't be directly globalized in version.php. When updating,
* we're including version.php from another installation and don't want
* these values to be overridden if already set.
*/
global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version, $wp_local_package;
require( ABSPATH . WPINC . '/version.php' );
require( ABSPATH . WPINC . '/load.php' );
// Check for the required PHP version and for the MySQL extension or a database drop-in.
wp_check_php_mysql_versions();
// Include files required for initialization.
require( ABSPATH . WPINC . '/class-wp-paused-extensions-storage.php' );
require( ABSPATH . WPINC . '/class-wp-fatal-error-handler.php' );
require( ABSPATH . WPINC . '/class-wp-recovery-mode-cookie-service.php' );
@ -28,14 +39,6 @@ require( ABSPATH . WPINC . '/error-protection.php' );
require( ABSPATH . WPINC . '/default-constants.php' );
require_once( ABSPATH . WPINC . '/plugin.php' );
/*
* These can't be directly globalized in version.php. When updating,
* we're including version.php from another installation and don't want
* these values to be overridden if already set.
*/
global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version, $wp_local_package;
require( ABSPATH . WPINC . '/version.php' );
/**
* If not already configured, `$blog_id` will default to 1 in a single site
* configuration. In multisite, it will be overridden by default in ms-settings.php.
@ -51,9 +54,6 @@ wp_initial_constants();
// Make sure we register the shutdown handler for fatal errors as soon as possible.
wp_register_fatal_error_handler();
// Check for the required PHP version and for the MySQL extension or a database drop-in.
wp_check_php_mysql_versions();
// WordPress calculates offsets from UTC.
date_default_timezone_set( 'UTC' );