Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/wp-includes/ms-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
* Use `get_current_network_id()` instead.
* @global bool $public Deprecated. Whether the site found on load is public.
* Use `get_site()->public` instead.
* @global string $table_prefix Database table prefix.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global populated in wp-config.php.

* @global wpdb $wpdb WordPress database abstraction object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global populated by require_wp_db().

*/
global $current_site, $current_blog, $domain, $path, $site_id, $public;
global $current_site, $current_blog, $domain, $path, $site_id, $public, $table_prefix, $wpdb;

/** WP_Network class */
require_once ABSPATH . WPINC . '/class-wp-network.php';
Expand Down
4 changes: 3 additions & 1 deletion src/wp-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
* @global string[] $required_php_extensions The names of required PHP extensions.
* @global string $required_mysql_version The minimum required MySQL version string.
* @global string $wp_local_package Locale code of the package.
* @global array $wp_filter WordPress filter hooks.
* @global string $table_prefix Database table prefix.
*/
global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_php_extensions, $required_mysql_version, $wp_local_package;
global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_php_extensions, $required_mysql_version, $wp_local_package, $wp_filter, $table_prefix;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's something curious below in how the $table_prefix is set:

/**
* @since 3.3.0
*
* @global string $table_prefix The database table prefix.
*/
if ( ! isset( $GLOBALS['table_prefix'] ) ) {
$GLOBALS['table_prefix'] = $table_prefix;
}

This to me looks like dead code. But in fact, it is pretty new: 61ae275

It was developed for Core-63627.

I wonder if explicitly globalizing $table_prefix that this could break how this was intended to be used, if $table_prefix is loaded in a lexical scope somehow which is distinct from the $table_prefix which is also a global. I'm not sure how this would work, but it gives me pause.

@SergeyBiryukov can you shed some light on this as you made that commit?

It may be safer to do this patch instead:

diff --git a/src/wp-settings.php b/src/wp-settings.php
index 023cdccd5e..87fa935aa1 100644
--- a/src/wp-settings.php
+++ b/src/wp-settings.php
@@ -100,7 +100,7 @@ if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) &
 	include WP_CONTENT_DIR . '/advanced-cache.php';
 
 	// Re-initialize any hooks added manually by advanced-cache.php.
-	if ( $wp_filter ) {
+	if ( isset( $wp_filter ) ) {
 		$wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter );
 	}
 }
@@ -140,7 +140,7 @@ require_wp_db();
  *
  * @global string $table_prefix The database table prefix.
  */
-if ( ! isset( $GLOBALS['table_prefix'] ) ) {
+if ( ! isset( $GLOBALS['table_prefix'] ) && isset( $table_prefix ) ) {
 	$GLOBALS['table_prefix'] = $table_prefix;
 }

But let's get confirmation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require ABSPATH . WPINC . '/version.php';
require ABSPATH . WPINC . '/compat-utf8.php';
require ABSPATH . WPINC . '/compat.php';
Expand Down
Loading