From 0ea00a75d19326c0991cd538acbf20d699cc4852 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 18 Oct 2011 19:37:07 +0000 Subject: [PATCH] Explicitly globalize $table_prefix in wp-settings.php in case WordPress isn't loaded in global scope. Use $_SERVER['PHP_SELF'], not $PHP_SELF. We need to keep $PHP_SELF for backwards compatibility reasons (many, many plugins rely on it). props mrtorrent, fixes #17749. git-svn-id: https://develop.svn.wordpress.org/trunk@18993 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/vars.php | 8 ++++---- wp-settings.php | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-includes/vars.php b/wp-includes/vars.php index fb526b5959..d28d99b972 100644 --- a/wp-includes/vars.php +++ b/wp-includes/vars.php @@ -16,11 +16,11 @@ if ( is_admin() ) { // wp-admin pages are checked more carefully if ( is_network_admin() ) - preg_match('#/wp-admin/network/?(.*?)$#i', $PHP_SELF, $self_matches); + preg_match('#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches); elseif ( is_user_admin() ) - preg_match('#/wp-admin/user/?(.*?)$#i', $PHP_SELF, $self_matches); + preg_match('#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches); else - preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches); + preg_match('#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches); $pagenow = $self_matches[1]; $pagenow = trim($pagenow, '/'); $pagenow = preg_replace('#\?.*?$#', '', $pagenow); @@ -33,7 +33,7 @@ if ( is_admin() ) { $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried) } } else { - if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $PHP_SELF, $self_matches) ) + if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $_SERVER['PHP_SELF'], $self_matches) ) $pagenow = strtolower($self_matches[1]); else $pagenow = 'index.php'; diff --git a/wp-settings.php b/wp-settings.php index 6c5346f98b..7897e73478 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -75,6 +75,7 @@ require( ABSPATH . WPINC . '/plugin.php' ); require_wp_db(); // Set the database table prefix and the format specifiers for database table columns. +$GLOBALS['table_prefix'] = $table_prefix; wp_set_wpdb_vars(); // Start the WordPress object cache, or an external object cache if the drop-in is present.