<!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>[41661] trunk: Multisite: Use `get_current_blog_id()` instead of `$wpdb->blogid`.</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 { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { 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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/41661">41661</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/41661","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>jeremyfelt</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-10-02 01:43:48 +0000 (Mon, 02 Oct 2017)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Multisite: Use `get_current_blog_id()` instead of `$wpdb->blogid`.
`get_current_blog_id()` is more appropriate for determining the ID of the current site in most cases. This eliminates the need for the global `$wpdb` in several functions and is better than the implicit global used in admin pages.
Props bnap00, spacedmonkey.
Fixes <a href="https://core.trac.wordpress.org/ticket/41684">#41684</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesupgradephp">trunk/src/wp-admin/includes/upgrade.php</a></li>
<li><a href="#trunksrcwpadminmsdeletesitephp">trunk/src/wp-admin/ms-delete-site.php</a></li>
<li><a href="#trunksrcwpadminusernewphp">trunk/src/wp-admin/user-new.php</a></li>
<li><a href="#trunksrcwpincludesmsblogsphp">trunk/src/wp-includes/ms-blogs.php</a></li>
<li><a href="#trunksrcwpincludesmsdefaultconstantsphp">trunk/src/wp-includes/ms-default-constants.php</a></li>
<li><a href="#trunksrcwpincludesmsfunctionsphp">trunk/src/wp-includes/ms-functions.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitesitephp">trunk/tests/phpunit/tests/multisite/site.php</a></li>
<li><a href="#trunktestsphpunittestsusermultisitephp">trunk/tests/phpunit/tests/user/multisite.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesupgradephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/upgrade.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/upgrade.php 2017-10-02 00:21:06 UTC (rev 41660)
+++ trunk/src/wp-admin/includes/upgrade.php 2017-10-02 01:43:48 UTC (rev 41661)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -433,10 +433,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_flush();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_multisite() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
- $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
- else
- $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_id = get_current_blog_id();
+
+ if ( $wpdb->get_row( $wpdb->prepare( 'SELECT blog_id FROM %s WHERE blog_id = %d', $wpdb->blog_versions, $site_id ) ) ) {
+ $wpdb->query( $wpdb->prepare( 'UPDATE %s SET db_version = %d WHERE blog_id = %d', $wpdb->blog_versions, $wp_db_version, $site_id ) );
+ } else {
+ $wpdb->query( $wpdb->prepare( 'INSERT INTO %s ( `blog_id` , `db_version` , `last_updated` ) VALUES ( %d, %d, %s);', $wpdb->blog_versions, $site_id, $wp_db_version, NOW() ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1257,7 +1260,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $start += 20;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- refresh_blog_details( $wpdb->blogid );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ refresh_blog_details();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpadminmsdeletesitephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/ms-delete-site.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/ms-delete-site.php 2017-10-02 00:21:06 UTC (rev 41660)
+++ trunk/src/wp-admin/ms-delete-site.php 2017-10-02 01:43:48 UTC (rev 41661)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -17,7 +17,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( hash_equals( get_option( 'delete_blog_hash' ), $_GET['h'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_delete_blog( $wpdb->blogid );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_delete_blog( get_current_blog_id() );
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_die( sprintf( __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ), get_network()->site_name ) );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( __( "I'm sorry, the link you clicked is stale. Please select another option." ) );
</span></span></pre></div>
<a id="trunksrcwpadminusernewphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/user-new.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/user-new.php 2017-10-02 00:21:06 UTC (rev 41660)
+++ trunk/src/wp-admin/user-new.php 2017-10-02 01:43:48 UTC (rev 41661)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -156,7 +156,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST['role'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => get_current_blog_id(), 'new_role' => $_REQUEST['role'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_POST[ 'noconfirmation' ] ) && current_user_can( 'manage_network_users' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $new_user = wpmu_activate_signup( $key );
</span></span></pre></div>
<a id="trunksrcwpincludesmsblogsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/ms-blogs.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/ms-blogs.php 2017-10-02 00:21:06 UTC (rev 41660)
+++ trunk/src/wp-includes/ms-blogs.php 2017-10-02 01:43:48 UTC (rev 41661)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,13 +12,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Update the last_updated field for the current site.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since MU (3.0.0)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wpmu_update_blogs_date() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_id = get_current_blog_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_blog_details( $site_id, array( 'last_updated' => current_time( 'mysql', true ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Fires after the blog details are updated.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -26,7 +24,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $blog_id Site ID.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- do_action( 'wpmu_blog_updated', $wpdb->blogid );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ do_action( 'wpmu_blog_updated', $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesmsdefaultconstantsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/ms-default-constants.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/ms-default-constants.php 2017-10-02 00:21:06 UTC (rev 41660)
+++ trunk/src/wp-includes/ms-default-constants.php 2017-10-02 01:43:48 UTC (rev 41661)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,12 +14,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * wp-includes/ms-files.php (wp-content/blogs.php in MU).
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.0.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function ms_upload_constants() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> // This filter is attached in ms-default-filters.php but that file is not included during SHORTINIT.
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -33,11 +29,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Note, the main site in a post-MU network uses wp-content/uploads.
</span><span class="cx" style="display: block; padding: 0 10px"> // This is handled in wp_upload_dir() by ignoring UPLOADS for this case.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! defined( 'UPLOADS' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_id = get_current_blog_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ define( 'UPLOADS', UPLOADBLOGSDIR . '/' . $site_id . '/files/' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Uploads dir relative to ABSPATH
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . $site_id . '/files/' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesmsfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/ms-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/ms-functions.php 2017-10-02 00:21:06 UTC (rev 41660)
+++ trunk/src/wp-includes/ms-functions.php 2017-10-02 01:43:48 UTC (rev 41661)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -34,19 +34,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since MU (3.0.0) 1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param int $user_id The unique ID of the user
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_Site|void The blog object
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_active_blog_for_user( $user_id ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $blogs = get_blogs_of_user( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $blogs ) )
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !is_multisite() )
- return $blogs[$wpdb->blogid];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! is_multisite() ) {
+ return $blogs[ get_current_blog_id() ];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $primary_blog = get_user_meta( $user_id, 'primary_blog', true );
</span><span class="cx" style="display: block; padding: 0 10px"> $first_blog = current($blogs);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2219,7 +2217,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $current_user = wp_get_current_user();
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $blog_id == 0 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog_id = $wpdb->blogid;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = get_current_blog_id();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunittestsmultisitesitephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/multisite/site.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/site.php 2017-10-02 00:21:06 UTC (rev 41660)
+++ trunk/tests/phpunit/tests/multisite/site.php 2017-10-02 01:43:48 UTC (rev 41661)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -363,7 +363,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wpmu_update_blogs_date();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // compare the update time with the current time, allow delta < 2
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $blog = get_site( $wpdb->blogid );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog = get_site( get_current_blog_id() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $current_time = time();
</span><span class="cx" style="display: block; padding: 0 10px"> $time_difference = $current_time - strtotime( $blog->last_updated );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertLessThan( 2, $time_difference );
</span></span></pre></div>
<a id="trunktestsphpunittestsusermultisitephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/user/multisite.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user/multisite.php 2017-10-02 00:21:06 UTC (rev 41660)
+++ trunk/tests/phpunit/tests/user/multisite.php 2017-10-02 01:43:48 UTC (rev 41661)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -120,7 +120,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( $user1_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_blog_user() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( is_blog_user( $wpdb->blogid ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( is_blog_user( get_current_blog_id() ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $blog_ids = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -149,12 +149,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( is_user_member_of_blog() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( $user1_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_id = get_current_blog_id();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_user_member_of_blog() );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_user_member_of_blog( 0, 0 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( is_user_member_of_blog( 0, $wpdb->blogid ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( is_user_member_of_blog( 0, $site_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_user_member_of_blog( $user1_id ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( is_user_member_of_blog( $user1_id, $wpdb->blogid ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( is_user_member_of_blog( $user1_id, $site_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $blog_ids = self::factory()->blog->create_many( 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $blog_ids as $blog_id ) {
</span></span></pre>
</div>
</div>
</body>
</html>