From 0b9a4373174e056fd57831c4061b83317be155d2 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Thu, 8 Oct 2015 21:44:11 +0000 Subject: [PATCH] Make `$blog_id` explicitly global. `$blog_id` is used in both single and multisite configurations as a global variable, though has never been explicitly marked as such in the global scope. This can cause confusion depending on how core is loaded. Fixes #34217. git-svn-id: https://develop.svn.wordpress.org/trunk@34961 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/default-constants.php | 9 ++------- src/wp-settings.php | 9 +++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/default-constants.php b/src/wp-includes/default-constants.php index 1ec1b36350..795b9190dd 100644 --- a/src/wp-includes/default-constants.php +++ b/src/wp-includes/default-constants.php @@ -11,6 +11,8 @@ * @see wp_debug_mode() * * @since 3.0.0 + * + * @global int $blog_id */ function wp_initial_constants() { global $blog_id; @@ -28,13 +30,6 @@ function wp_initial_constants() { define( 'WP_MAX_MEMORY_LIMIT', '256M' ); } - /** - * The $blog_id global, which you can change in the config allows you to create a simple - * multiple blog installation using just one WordPress and changing $blog_id around. - * - * @global int $blog_id - * @since 2.0.0 - */ if ( ! isset($blog_id) ) $blog_id = 1; diff --git a/src/wp-settings.php b/src/wp-settings.php index 55b8dae211..e0e39754ea 100644 --- a/src/wp-settings.php +++ b/src/wp-settings.php @@ -29,6 +29,15 @@ require( ABSPATH . WPINC . '/default-constants.php' ); global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version; 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. + * + * @global int $blog_id + * @since 2.0.0 + */ +global $blog_id; + // Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, SCRIPT_DEBUG, WP_CONTENT_DIR and WP_CACHE. wp_initial_constants();