WordPress.org

Make WordPress Core

Changeset 46183


Ignore:
Timestamp:
09/19/2019 12:01:03 PM (2 months ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r46105 r46183  
    132132
    133133    if ( version_compare( $required_php_version, $php_version, '>' ) ) {
    134         wp_load_translations_early();
    135 
    136134        $protocol = wp_get_server_protocol();
    137135        header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
    138136        header( 'Content-Type: text/html; charset=utf-8' );
    139         /* translators: 1: Current PHP version number, 2: WordPress version number, 3: Minimum required PHP version number. */
    140         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 );
     137        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 );
    141138        exit( 1 );
    142139    }
  • trunk/src/wp-settings.php

    r46111 r46183  
    1616define( 'WPINC', 'wp-includes' );
    1717
     18/*
     19 * These can't be directly globalized in version.php. When updating,
     20 * we're including version.php from another installation and don't want
     21 * these values to be overridden if already set.
     22 */
     23global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version, $wp_local_package;
     24require( ABSPATH . WPINC . '/version.php' );
     25require( ABSPATH . WPINC . '/load.php' );
     26
     27// Check for the required PHP version and for the MySQL extension or a database drop-in.
     28wp_check_php_mysql_versions();
     29
    1830// Include files required for initialization.
    19 require( ABSPATH . WPINC . '/load.php' );
    2031require( ABSPATH . WPINC . '/class-wp-paused-extensions-storage.php' );
    2132require( ABSPATH . WPINC . '/class-wp-fatal-error-handler.php' );
     
    2940require_once( ABSPATH . WPINC . '/plugin.php' );
    3041
    31 /*
    32  * These can't be directly globalized in version.php. When updating,
    33  * we're including version.php from another installation and don't want
    34  * these values to be overridden if already set.
    35  */
    36 global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version, $wp_local_package;
    37 require( ABSPATH . WPINC . '/version.php' );
    38 
    3942/**
    4043 * If not already configured, `$blog_id` will default to 1 in a single site
     
    5154// Make sure we register the shutdown handler for fatal errors as soon as possible.
    5255wp_register_fatal_error_handler();
    53 
    54 // Check for the required PHP version and for the MySQL extension or a database drop-in.
    55 wp_check_php_mysql_versions();
    5656
    5757// WordPress calculates offsets from UTC.
Note: See TracChangeset for help on using the changeset viewer.