From 3349f1a527761eed3aa2d48050d80a9b62fc6860 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 16 Jul 2023 12:14:47 +0000 Subject: [PATCH] Bootstrap/Load: Require `wp-includes/compat.php` in `src/index.php`. This allows for using polyfill functions if `src/index.php` is the entry point (this file exists as a reminder to build the assets, and is different from the actual `index.php` file that gets built and boots WordPress). Includes: * Moving the check for the required PHP and MySQL versions earlier. * Making the load order consistent between `src/index.php`, `wp-load.php`, and `wp-settings.php`. Follow-up to [46183], [56006], [56007]. Props westonruter, Presskopp, joemcgill, SergeyBiryukov. See #58206. git-svn-id: https://develop.svn.wordpress.org/trunk@56241 602fd350-edb4-49c9-b593-d223f7449a82 --- src/index.php | 9 ++++++--- src/wp-load.php | 11 ++++++----- src/wp-settings.php | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/index.php b/src/index.php index 9762828dd4..91c0517857 100644 --- a/src/index.php +++ b/src/index.php @@ -21,16 +21,19 @@ if ( file_exists( ABSPATH . 'wp-includes/js/dist/edit-post.js' ) ) { } define( 'WPINC', 'wp-includes' ); +require_once ABSPATH . WPINC . '/version.php'; +require_once ABSPATH . WPINC . '/compat.php'; require_once 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(); + // Standardize $_SERVER variables across setups. wp_fix_server_vars(); -require_once ABSPATH . WPINC . '/functions.php'; define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); -require_once ABSPATH . WPINC . '/version.php'; +require_once ABSPATH . WPINC . '/functions.php'; -wp_check_php_mysql_versions(); wp_load_translations_early(); // Die with an error message. diff --git a/src/wp-load.php b/src/wp-load.php index fe2f7c3be6..d3787d108e 100644 --- a/src/wp-load.php +++ b/src/wp-load.php @@ -59,12 +59,17 @@ if ( file_exists( ABSPATH . 'wp-config.php' ) ) { // A config file doesn't exist. define( 'WPINC', 'wp-includes' ); + require_once ABSPATH . WPINC . '/version.php'; + require_once ABSPATH . WPINC . '/compat.php'; require_once 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(); + // Standardize $_SERVER variables across setups. wp_fix_server_vars(); - require_once ABSPATH . WPINC . '/compat.php'; + define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); require_once ABSPATH . WPINC . '/functions.php'; $path = wp_guess_url() . '/wp-admin/setup-config.php'; @@ -75,10 +80,6 @@ if ( file_exists( ABSPATH . 'wp-config.php' ) ) { exit; } - define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); - require_once ABSPATH . WPINC . '/version.php'; - - wp_check_php_mysql_versions(); wp_load_translations_early(); // Die with an error message. diff --git a/src/wp-settings.php b/src/wp-settings.php index 52e7209f86..f59e280f08 100644 --- a/src/wp-settings.php +++ b/src/wp-settings.php @@ -31,13 +31,13 @@ define( 'WPINC', 'wp-includes' ); */ 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 . '/compat.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 . '/compat.php'; 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';