From 7a86de87fb9e8f331db383eec0dfad69fc358310 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 4 Oct 2012 12:40:09 +0000 Subject: [PATCH] Reduce use of global. Use get_blog_details() instead. fixes #22090 git-svn-id: http://core.svn.wordpress.org/trunk@22108 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-importer.php | 5 ----- wp-admin/ms-delete-site.php | 4 +++- wp-includes/class-wp-xmlrpc-server.php | 3 ++- wp-includes/functions.php | 8 ++++---- wp-includes/ms-blogs.php | 8 +++++--- wp-includes/ms-load.php | 10 ++++++---- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/wp-admin/includes/class-wp-importer.php b/wp-admin/includes/class-wp-importer.php index 2b4774bcf3..0cfc9fe8ab 100644 --- a/wp-admin/includes/class-wp-importer.php +++ b/wp-admin/includes/class-wp-importer.php @@ -132,9 +132,6 @@ class WP_Importer { exit(); } $blog_id = (int) $blog->blog_id; - // Restore global $current_blog - global $current_blog; - $current_blog = $blog; } if ( function_exists( 'is_multisite' ) ) { @@ -212,8 +209,6 @@ class WP_Importer { * @return bool */ function is_user_over_quota() { - global $current_blog; - if ( function_exists( 'upload_is_user_over_quota' ) ) { if ( upload_is_user_over_quota( 1 ) ) { echo "Sorry, you have used your upload quota.\n"; diff --git a/wp-admin/ms-delete-site.php b/wp-admin/ms-delete-site.php index 95f0aa091d..7d772c2658 100644 --- a/wp-admin/ms-delete-site.php +++ b/wp-admin/ms-delete-site.php @@ -25,6 +25,8 @@ if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) } } +$blog = get_blog_details(); + $title = __( 'Delete Site' ); $parent_file = 'tools.php'; require_once( './admin-header.php' ); @@ -72,7 +74,7 @@ Webmaster
-

+

domain; $path = $current_blog->path . 'xmlrpc.php'; diff --git a/wp-includes/functions.php b/wp-includes/functions.php index dda3b8da28..8615e323f4 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3118,13 +3118,13 @@ function wp_suspend_cache_invalidation($suspend = true) { * @return bool True if not multisite or $blog_id is main site */ function is_main_site( $blog_id = '' ) { - global $current_site, $current_blog; + global $current_site; - if ( !is_multisite() ) + if ( ! is_multisite() ) return true; - if ( !$blog_id ) - $blog_id = $current_blog->blog_id; + if ( ! $blog_id ) + $blog_id = get_current_blog_id(); return $blog_id == $current_site->blog_id; } diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index 653d186917..1ef22def41 100644 --- a/wp-includes/ms-blogs.php +++ b/wp-includes/ms-blogs.php @@ -118,11 +118,11 @@ function get_id_from_blogname( $slug ) { * * @since MU * - * @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against. + * @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against. Optional. If not specified the current blog ID is used. * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true. * @return object Blog details. */ -function get_blog_details( $fields, $get_all = true ) { +function get_blog_details( $fields = null, $get_all = true ) { global $wpdb; if ( is_array($fields ) ) { @@ -166,7 +166,9 @@ function get_blog_details( $fields, $get_all = true ) { return false; } } else { - if ( !is_numeric( $fields ) ) + if ( ! $fields ) + $blog_id = get_current_blog_id(); + elseif ( ! is_numeric( $fields ) ) $blog_id = get_id_from_blogname( $fields ); else $blog_id = $fields; diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php index 58826e7804..73c446ffc5 100644 --- a/wp-includes/ms-load.php +++ b/wp-includes/ms-load.php @@ -69,7 +69,9 @@ function wp_get_active_network_plugins() { * @return bool|string Returns true on success, or drop-in file to include. */ function ms_site_check() { - global $wpdb, $current_blog; + global $wpdb; + + $blog = get_blog_details(); // Allow short-circuiting $check = apply_filters('ms_site_check', null); @@ -80,21 +82,21 @@ function ms_site_check() { if ( is_super_admin() ) return true; - if ( '1' == $current_blog->deleted ) { + if ( '1' == $blog->deleted ) { if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) return WP_CONTENT_DIR . '/blog-deleted.php'; else wp_die( __( 'This user has elected to delete their account and the content is no longer available.' ), '', array( 'response' => 410 ) ); } - if ( '2' == $current_blog->deleted ) { + if ( '2' == $blog->deleted ) { if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) return WP_CONTENT_DIR . '/blog-inactive.php'; else wp_die( sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact %1$s.' ), str_replace( '@', ' AT ', get_site_option( 'admin_email', "support@{$current_site->domain}" ) ) ) ); } - if ( $current_blog->archived == '1' || $current_blog->spam == '1' ) { + if ( $blog->archived == '1' || $blog->spam == '1' ) { if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) return WP_CONTENT_DIR . '/blog-suspended.php'; else