<!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>[41883] trunk: Multisite: Revert [41719].</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/41883">41883</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/41883","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>flixos90</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-10-16 22:28:52 +0000 (Mon, 16 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: Revert <a href="https://core.trac.wordpress.org/changeset/41719">[41719]</a>.
While `get_site_by()` makes sense as a more explicit and less complex replacement for `get_blog_details()`, it is not ready yet in terms of caching, where it currently falls short of the older function under specific circumstances.
See <a href="https://core.trac.wordpress.org/ticket/40180">#40180</a>, <a href="https://core.trac.wordpress.org/ticket/40228">#40228</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpsitephp">trunk/src/wp-includes/class-wp-site.php</a></li>
<li><a href="#trunksrcwpincludesmsblogsphp">trunk/src/wp-includes/ms-blogs.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitesitephp">trunk/tests/phpunit/tests/multisite/site.php</a></li>
<li><a href="#trunktestsphpunittestsmultisitesiteDetailsphp">trunk/tests/phpunit/tests/multisite/siteDetails.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpsitephp"></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/class-wp-site.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-site.php 2017-10-16 21:35:15 UTC (rev 41882)
+++ trunk/src/wp-includes/class-wp-site.php 2017-10-16 22:28:52 UTC (rev 41883)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -330,14 +330,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_set( $this->blog_id, $details, 'site-details' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Filters a blog's details.
- *
- * @since MU (3.0.0)
- * @deprecated 4.7.0 Use site_details
- *
- * @param object $details The blog details.
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** This filter is documented in wp-includes/ms-blogs.php */
</ins><span class="cx" style="display: block; padding: 0 10px"> $details = apply_filters_deprecated( 'blog_details', array( $details ), '4.7.0', 'site_details' );
</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="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-16 21:35:15 UTC (rev 41882)
+++ trunk/src/wp-includes/ms-blogs.php 2017-10-16 22:28:52 UTC (rev 41883)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -93,8 +93,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieve the details for a blog from the blogs table and blog options.
</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">- * @since 4.9.0 Use get_site_by() internally.
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @global wpdb $wpdb WordPress database abstraction object.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param int|string|array $fields Optional. A blog ID, a blog slug, or an array of fields to query against.
</span><span class="cx" style="display: block; padding: 0 10px"> * If not specified the current blog ID is used.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $get_all Whether to retrieve all details or only the details in the blogs table.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,46 +103,138 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_Site|false Blog details on success. False on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_blog_details( $fields = null, $get_all = true ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_array( $fields ) ) {
- if ( isset( $fields['blog_id'] ) ) {
- $field = 'id';
- $value = (int) $fields['blog_id'];
- } elseif ( isset( $fields['domain'] ) && isset( $fields['path'] ) ) {
- $field = 'url';
- $value = $fields['domain'] . '/' . ltrim( $fields['path'], '/' );
- } elseif ( isset( $fields['domain'] ) && is_subdomain_install() ) {
- $field = 'domain';
- $value = $fields['domain'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wpdb;
+
+ if ( is_array($fields ) ) {
+ if ( isset($fields['blog_id']) ) {
+ $blog_id = $fields['blog_id'];
+ } elseif ( isset($fields['domain']) && isset($fields['path']) ) {
+ $key = md5( $fields['domain'] . $fields['path'] );
+ $blog = wp_cache_get($key, 'blog-lookup');
+ if ( false !== $blog )
+ return $blog;
+ if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
+ $nowww = substr( $fields['domain'], 4 );
+ $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) );
+ } else {
+ $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) );
+ }
+ if ( $blog ) {
+ wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
+ $blog_id = $blog->blog_id;
+ } else {
+ return false;
+ }
+ } elseif ( isset($fields['domain']) && is_subdomain_install() ) {
+ $key = md5( $fields['domain'] );
+ $blog = wp_cache_get($key, 'blog-lookup');
+ if ( false !== $blog )
+ return $blog;
+ if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
+ $nowww = substr( $fields['domain'], 4 );
+ $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) );
+ } else {
+ $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) );
+ }
+ if ( $blog ) {
+ wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
+ $blog_id = $blog->blog_id;
+ } else {
+ return false;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $fields ) {
- $field = 'id';
- $value = get_current_blog_id();
- } elseif ( ! is_numeric( $fields ) ) {
- $field = 'slug';
- $value = $fields;
- } else {
- $field = 'id';
- $value = (int) $fields;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $fields )
+ $blog_id = get_current_blog_id();
+ elseif ( ! is_numeric( $fields ) )
+ $blog_id = get_id_from_blogname( $fields );
+ else
+ $blog_id = $fields;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site = get_site_by( $field, $value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $blog_id = (int) $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">- if ( ! $site ) {
- return false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $all = $get_all == true ? '' : 'short';
+ $details = wp_cache_get( $blog_id . $all, 'blog-details' );
+
+ if ( $details ) {
+ if ( ! is_object( $details ) ) {
+ if ( $details == -1 ) {
+ return false;
+ } else {
+ // Clear old pre-serialized objects. Cache clients do better with that.
+ wp_cache_delete( $blog_id . $all, 'blog-details' );
+ unset($details);
+ }
+ } else {
+ return $details;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Try the other cache.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $get_all ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Prepopulate magic properties for backward compatibility.
- foreach ( array( 'blogname', 'siteurl', 'post_count', 'home' ) as $detail ) {
- $site->$detail = $site->$detail;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $details = wp_cache_get( $blog_id . 'short', 'blog-details' );
+ } else {
+ $details = wp_cache_get( $blog_id, 'blog-details' );
+ // If short was requested and full cache is set, we can return.
+ if ( $details ) {
+ if ( ! is_object( $details ) ) {
+ if ( $details == -1 ) {
+ return false;
+ } else {
+ // Clear old pre-serialized objects. Cache clients do better with that.
+ wp_cache_delete( $blog_id, 'blog-details' );
+ unset($details);
+ }
+ } else {
+ return $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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $site;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty($details) ) {
+ $details = WP_Site::get_instance( $blog_id );
+ if ( ! $details ) {
+ // Set the full cache.
+ wp_cache_set( $blog_id, -1, 'blog-details' );
+ return false;
+ }
+ }
+
+ if ( ! $details instanceof WP_Site ) {
+ $details = new WP_Site( $details );
+ }
+
+ if ( ! $get_all ) {
+ wp_cache_set( $blog_id . $all, $details, 'blog-details' );
+ return $details;
+ }
+
+ switch_to_blog( $blog_id );
+ $details->blogname = get_option( 'blogname' );
+ $details->siteurl = get_option( 'siteurl' );
+ $details->post_count = get_option( 'post_count' );
+ $details->home = get_option( 'home' );
+ restore_current_blog();
+
+ /**
+ * Filters a blog's details.
+ *
+ * @since MU (3.0.0)
+ * @deprecated 4.7.0 Use site_details
+ *
+ * @param object $details The blog details.
+ */
+ $details = apply_filters_deprecated( 'blog_details', array( $details ), '4.7.0', 'site_details' );
+
+ wp_cache_set( $blog_id . $all, $details, 'blog-details' );
+
+ $key = md5( $details->domain . $details->path );
+ wp_cache_set( $key, $details, 'blog-lookup' );
+
+ return $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="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-16 21:35:15 UTC (rev 41882)
+++ trunk/tests/phpunit/tests/multisite/site.php 2017-10-16 22:28:52 UTC (rev 41883)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -118,21 +118,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // $get_all = false, only retrieve details from the blogs table
</span><span class="cx" style="display: block; padding: 0 10px"> $details = get_blog_details( $blog_id, false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cached_details = wp_cache_get( $blog_id, 'sites' );
- $this->assertNotFalse( $cached_details );
- $this->assertEqualSets( get_object_vars( $details ), get_object_vars( $cached_details ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Combine domain and path for a site specific cache key.
+ $key = md5( $details->domain . $details->path );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // get_blogaddress_by_name()
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'http://' . $details->domain . $details->path, get_blogaddress_by_name( trim( $details->path, '/' ) ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // This is empty until get_blog_details() is called with $get_all = true
- $this->assertEquals( false, wp_cache_get( $blog_id, 'site-details' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // These are empty until get_blog_details() is called with $get_all = true
+ $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
+ $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // $get_all = true, populate the full blog-details cache and the blog slug lookup cache
</span><span class="cx" style="display: block; padding: 0 10px"> $details = get_blog_details( $blog_id, true );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cached_details = wp_cache_get( $blog_id, 'site-details' );
- $this->assertNotFalse( $cached_details );
- $this->assertEqualSets( get_object_vars( $details ), get_object_vars( $cached_details ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $details, wp_cache_get( $blog_id, 'blog-details' ) );
+ $this->assertEquals( $details, wp_cache_get( $key, 'blog-lookup' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check existence of each database table for the created site.
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $wpdb->tables( 'blog', false ) as $table ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -195,8 +196,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Delete the site without forcing a table drop.
</span><span class="cx" style="display: block; padding: 0 10px"> wpmu_delete_blog( $blog_id, false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( false, wp_cache_get( $blog_id, 'sites' ) );
- $this->assertEquals( false, wp_cache_get( $blog_id, 'site-details' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
+ $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
+ $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
</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">@@ -232,8 +234,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Delete the site and force a table drop.
</span><span class="cx" style="display: block; padding: 0 10px"> wpmu_delete_blog( $blog_id, true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( false, wp_cache_get( $blog_id, 'sites' ) );
- $this->assertEquals( false, wp_cache_get( $blog_id, 'site-details' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
+ $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
+ $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
</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">@@ -269,8 +272,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Delete the site and force a table drop.
</span><span class="cx" style="display: block; padding: 0 10px"> wpmu_delete_blog( $blog_id, true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( false, wp_cache_get( $blog_id, 'sites' ) );
- $this->assertEquals( false, wp_cache_get( $blog_id, 'site-details' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
+ $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
+ $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
</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">@@ -386,21 +390,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Prime the cache for an invalid site.
</span><span class="cx" style="display: block; padding: 0 10px"> get_blog_details( $blog_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">- // When the cache is primed with an invalid site, the value is not set.
- $this->assertFalse( wp_cache_get( $blog_id, 'site-details' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // When the cache is primed with an invalid site, the value is set to -1.
+ $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Create a site in the invalid site's place.
</span><span class="cx" style="display: block; padding: 0 10px"> self::factory()->blog->create();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // When a new site is created, its cache is cleared through refresh_blog_details.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( wp_cache_get( $blog_id, 'site-details' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $blog = get_blog_details( $blog_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // When the cache is refreshed, it should now equal the site data.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cached_blog = wp_cache_get( $blog_id, 'site-details' );
- $this->assertNotFalse( $cached_blog );
- $this->assertEqualSets( get_object_vars( $blog ), get_object_vars( $cached_blog ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $blog, wp_cache_get( $blog_id, '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="trunktestsphpunittestsmultisitesiteDetailsphp"></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/siteDetails.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/multisite/siteDetails.php 2017-10-16 21:35:15 UTC (rev 41882)
+++ trunk/tests/phpunit/tests/multisite/siteDetails.php 2017-10-16 22:28:52 UTC (rev 41883)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -32,6 +32,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 40063
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_whitelisted_option_deletes_blog_details_cache( $whitelisted_option, $temporary_value ) {
+ $blog_details = get_blog_details();
+
+ $original_value = $blog_details->$whitelisted_option;
+ update_option( $whitelisted_option, $temporary_value );
+
+ $cached_result = wp_cache_get( $blog_details->id, 'blog-details' );
+
+ /* Reset to original value. */
+ update_option( $whitelisted_option, $original_value );
+
+ $this->assertFalse( $cached_result );
+ }
+
+ /**
+ * @dataProvider data_whitelisted_options
+ *
+ * @ticket 40063
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public function test_update_whitelisted_option_does_not_delete_site_cache( $whitelisted_option, $temporary_value ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $site = get_site();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -51,6 +70,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 40063
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update_whitelisted_option_does_not_delete_short_blog_details_cache( $whitelisted_option, $temporary_value ) {
+ $blog_details = get_blog_details( null, false );
+
+ $original_value = get_option( $whitelisted_option );
+ update_option( $whitelisted_option, $temporary_value );
+
+ $cached_result = wp_cache_get( $blog_details->id . 'short', 'blog-details' );
+
+ /* Reset to original value. */
+ update_option( $whitelisted_option, $original_value );
+
+ $this->assertNotFalse( $cached_result );
+ }
+
+ /**
+ * @dataProvider data_whitelisted_options
+ *
+ * @ticket 40063
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public function test_update_whitelisted_option_does_not_update_sites_last_changed( $whitelisted_option, $temporary_value ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $last_changed = wp_cache_get_last_changed( 'sites' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>