Skip to content

Commit

Permalink
Reduce use of global. Use get_blog_details() instead. fixes #22090
Browse files Browse the repository at this point in the history
git-svn-id: http://core.svn.wordpress.org/trunk@22108 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
Ryan Boren committed Oct 4, 2012
1 parent 830e300 commit 7a86de8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
5 changes: 0 additions & 5 deletions wp-admin/includes/class-wp-importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ function set_blog( $blog_id ) {
exit();
}
$blog_id = (int) $blog->blog_id;
// Restore global $current_blog
global $current_blog;
$current_blog = $blog;
}

if ( function_exists( 'is_multisite' ) ) {
Expand Down Expand Up @@ -212,8 +209,6 @@ function bump_request_timeout( $val ) {
* @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";
Expand Down
4 changes: 3 additions & 1 deletion wp-admin/ms-delete-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
}
}

$blog = get_blog_details();

$title = __( 'Delete Site' );
$parent_file = 'tools.php';
require_once( './admin-header.php' );
Expand Down Expand Up @@ -72,7 +74,7 @@
<form method="post" name="deletedirect">
<?php wp_nonce_field( 'delete-blog' ) ?>
<input type="hidden" name="action" value="deleteblog" />
<p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong><?php printf( __( "I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again." ), is_subdomain_install() ? $current_blog->domain : $current_blog->domain . $current_blog->path ); ?></strong></label></p>
<p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong><?php printf( __( "I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again." ), is_subdomain_install() ? $blog->domain : $blog->domain . $blog->path ); ?></strong></label></p>
<?php submit_button( __( 'Delete My Site Permanently' ) ); ?>
</form>
<?php
Expand Down
3 changes: 2 additions & 1 deletion wp-includes/class-wp-xmlrpc-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -3660,7 +3660,8 @@ function blogger_getUsersBlogs($args) {
* @access protected
*/
function _multisite_getUsersBlogs($args) {
global $current_blog;
$current_blog = get_blog_details();

$domain = $current_blog->domain;
$path = $current_blog->path . 'xmlrpc.php';

Expand Down
8 changes: 4 additions & 4 deletions wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 5 additions & 3 deletions wp-includes/ms-blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions wp-includes/ms-load.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 <a href="mailto:%1$s">%1$s</a>.' ), 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
Expand Down

0 comments on commit 7a86de8

Please sign in to comment.