From 5f1cbd7165632604fbc26a2127f2ad96a4af4a2c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Sep 2019 12:01:03 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@46183 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/load.php | 5 +---- src/wp-settings.php | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index be56883040..e1472201b5 100644 --- a/src/wp-includes/load.php +++ b/src/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/src/wp-settings.php b/src/wp-settings.php index 5822ebde5b..a4d9a78316 100644 --- a/src/wp-settings.php +++ b/src/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' );