<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[22108] trunk: Reduce use of global.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/22108">22108</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2012-10-04 12:40:09 +0000 (Thu, 04 Oct 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Reduce use of global. Use get_blog_details() instead. fixes <a href="http://core.trac.wordpress.org/ticket/22090">#22090</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpimporterphp">trunk/wp-admin/includes/class-wp-importer.php</a></li>
<li><a href="#trunkwpadminmsdeletesitephp">trunk/wp-admin/ms-delete-site.php</a></li>
<li><a href="#trunkwpincludesclasswpxmlrpcserverphp">trunk/wp-includes/class-wp-xmlrpc-server.php</a></li>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
<li><a href="#trunkwpincludesmsblogsphp">trunk/wp-includes/ms-blogs.php</a></li>
<li><a href="#trunkwpincludesmsloadphp">trunk/wp-includes/ms-load.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpimporterphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-importer.php (22107 => 22108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-importer.php        2012-10-03 20:54:54 UTC (rev 22107)
+++ trunk/wp-admin/includes/class-wp-importer.php        2012-10-04 12:40:09 UTC (rev 22108)
</span><span class="lines">@@ -132,9 +132,6 @@
</span><span class="cx">                                 exit();
</span><span class="cx">                         }
</span><span class="cx">                         $blog_id = (int) $blog->blog_id;
</span><del>-                        // Restore global $current_blog
-                        global $current_blog;
-                        $current_blog = $blog;
</del><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ( function_exists( 'is_multisite' ) ) {
</span><span class="lines">@@ -212,8 +209,6 @@
</span><span class="cx">          * @return bool
</span><span class="cx">          */
</span><span class="cx">         function is_user_over_quota() {
</span><del>-                global $current_blog;
-
</del><span class="cx">                 if ( function_exists( 'upload_is_user_over_quota' ) ) {
</span><span class="cx">                         if ( upload_is_user_over_quota( 1 ) ) {
</span><span class="cx">                                 echo "Sorry, you have used your upload quota.\n";
</span></span></pre></div>
<a id="trunkwpadminmsdeletesitephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/ms-delete-site.php (22107 => 22108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/ms-delete-site.php        2012-10-03 20:54:54 UTC (rev 22107)
+++ trunk/wp-admin/ms-delete-site.php        2012-10-04 12:40:09 UTC (rev 22108)
</span><span class="lines">@@ -25,6 +25,8 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+$blog = get_blog_details();
+
</ins><span class="cx"> $title = __( 'Delete Site' );
</span><span class="cx"> $parent_file = 'tools.php';
</span><span class="cx"> require_once( './admin-header.php' );
</span><span class="lines">@@ -72,7 +74,7 @@
</span><span class="cx">         <form method="post" name="deletedirect">
</span><span class="cx">                 <?php wp_nonce_field( 'delete-blog' ) ?>
</span><span class="cx">                 <input type="hidden" name="action" value="deleteblog" />
</span><del>-                <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>
</del><ins>+                <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>
</ins><span class="cx">                 <?php submit_button( __( 'Delete My Site Permanently' ) ); ?>
</span><span class="cx">         </form>
</span><span class="cx">         <?php
</span></span></pre></div>
<a id="trunkwpincludesclasswpxmlrpcserverphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-xmlrpc-server.php (22107 => 22108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-xmlrpc-server.php        2012-10-03 20:54:54 UTC (rev 22107)
+++ trunk/wp-includes/class-wp-xmlrpc-server.php        2012-10-04 12:40:09 UTC (rev 22108)
</span><span class="lines">@@ -3660,7 +3660,8 @@
</span><span class="cx">          * @access protected
</span><span class="cx">          */
</span><span class="cx">         function _multisite_getUsersBlogs($args) {
</span><del>-                global $current_blog;
</del><ins>+                $current_blog = get_blog_details();
+
</ins><span class="cx">                 $domain = $current_blog->domain;
</span><span class="cx">                 $path = $current_blog->path . 'xmlrpc.php';
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (22107 => 22108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2012-10-03 20:54:54 UTC (rev 22107)
+++ trunk/wp-includes/functions.php        2012-10-04 12:40:09 UTC (rev 22108)
</span><span class="lines">@@ -3118,13 +3118,13 @@
</span><span class="cx"> * @return bool True if not multisite or $blog_id is main site
</span><span class="cx"> */
</span><span class="cx"> function is_main_site( $blog_id = '' ) {
</span><del>-        global $current_site, $current_blog;
</del><ins>+        global $current_site;
</ins><span class="cx">
</span><del>-        if ( !is_multisite() )
</del><ins>+        if ( ! is_multisite() )
</ins><span class="cx">                 return true;
</span><span class="cx">
</span><del>-        if ( !$blog_id )
-                $blog_id = $current_blog->blog_id;
</del><ins>+        if ( ! $blog_id )
+                $blog_id = get_current_blog_id();
</ins><span class="cx">
</span><span class="cx">         return $blog_id == $current_site->blog_id;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpincludesmsblogsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-blogs.php (22107 => 22108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-blogs.php        2012-10-03 20:54:54 UTC (rev 22107)
+++ trunk/wp-includes/ms-blogs.php        2012-10-04 12:40:09 UTC (rev 22108)
</span><span class="lines">@@ -118,11 +118,11 @@
</span><span class="cx"> *
</span><span class="cx"> * @since MU
</span><span class="cx"> *
</span><del>- * @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against.
</del><ins>+ * @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.
</ins><span class="cx"> * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true.
</span><span class="cx"> * @return object Blog details.
</span><span class="cx"> */
</span><del>-function get_blog_details( $fields, $get_all = true ) {
</del><ins>+function get_blog_details( $fields = null, $get_all = true ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx">
</span><span class="cx">         if ( is_array($fields ) ) {
</span><span class="lines">@@ -166,7 +166,9 @@
</span><span class="cx">                         return false;
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><del>-                if ( !is_numeric( $fields ) )
</del><ins>+                if ( ! $fields )
+                        $blog_id = get_current_blog_id();
+                elseif ( ! is_numeric( $fields ) )
</ins><span class="cx">                         $blog_id = get_id_from_blogname( $fields );
</span><span class="cx">                 else
</span><span class="cx">                         $blog_id = $fields;
</span></span></pre></div>
<a id="trunkwpincludesmsloadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-load.php (22107 => 22108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-load.php        2012-10-03 20:54:54 UTC (rev 22107)
+++ trunk/wp-includes/ms-load.php        2012-10-04 12:40:09 UTC (rev 22108)
</span><span class="lines">@@ -69,8 +69,10 @@
</span><span class="cx"> * @return bool|string Returns true on success, or drop-in file to include.
</span><span class="cx"> */
</span><span class="cx"> function ms_site_check() {
</span><del>-        global $wpdb, $current_blog;
</del><ins>+        global $wpdb;
</ins><span class="cx">
</span><ins>+        $blog = get_blog_details();
+
</ins><span class="cx">         // Allow short-circuiting
</span><span class="cx">         $check = apply_filters('ms_site_check', null);
</span><span class="cx">         if ( null !== $check )
</span><span class="lines">@@ -80,21 +82,21 @@
</span><span class="cx">         if ( is_super_admin() )
</span><span class="cx">                 return true;
</span><span class="cx">
</span><del>-        if ( '1' == $current_blog->deleted ) {
</del><ins>+        if ( '1' == $blog->deleted ) {
</ins><span class="cx">                 if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) )
</span><span class="cx">                         return WP_CONTENT_DIR . '/blog-deleted.php';
</span><span class="cx">                 else
</span><span class="cx">                         wp_die( __( 'This user has elected to delete their account and the content is no longer available.' ), '', array( 'response' => 410 ) );
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( '2' == $current_blog->deleted ) {
</del><ins>+        if ( '2' == $blog->deleted ) {
</ins><span class="cx">                 if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) )
</span><span class="cx">                         return WP_CONTENT_DIR . '/blog-inactive.php';
</span><span class="cx">                 else
</span><span class="cx">                         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}" ) ) ) );
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( $current_blog->archived == '1' || $current_blog->spam == '1' ) {
</del><ins>+        if ( $blog->archived == '1' || $blog->spam == '1' ) {
</ins><span class="cx">                 if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) )
</span><span class="cx">                         return WP_CONTENT_DIR . '/blog-suspended.php';
</span><span class="cx">                 else
</span></span></pre>
</div>
</div>
</body>
</html>