From 7c9d4950b7051839725287b1ce4e6f2c260ba7bc Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Sep 2019 12:02:58 +0000 Subject: [PATCH] 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 --- wp-includes/load.php | 5 +---- wp-includes/version.php | 2 +- wp-settings.php | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/wp-includes/load.php b/wp-includes/load.php index be56883040..e1472201b5 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -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 ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 2f491b5745..381c771916 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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. diff --git a/wp-settings.php b/wp-settings.php index 5822ebde5b..a4d9a78316 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -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' );