Multisite: Use get_sites() instead of a database lookup in get_id_from_blogname().

Because queries generated via `get_sites()` are cached, we can remove the `get_id_from_blogname` cache key.

Props flixos90.
Fixes #38175.


git-svn-id: https://develop.svn.wordpress.org/trunk@38659 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jeremy Felt
2016-09-27 18:17:23 +00:00
parent 1f143d995b
commit 8fcec07595
2 changed files with 16 additions and 22 deletions

View File

@@ -87,10 +87,6 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
$this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
// get_id_from_blogname(), see #20950
$this->assertEquals( $blog_id, get_id_from_blogname( $details->path ) );
$this->assertEquals( $blog_id, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) );
// get_blogaddress_by_name()
$this->assertEquals( 'http://' . $details->domain . $details->path, get_blogaddress_by_name( trim( $details->path, '/' ) ) );
@@ -138,7 +134,6 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
// Delete the site without forcing a table drop.
wpmu_delete_blog( $blog_id, false );
$this->assertEquals( false, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) );
$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' ) );
@@ -177,7 +172,6 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
// Delete the site and force a table drop.
wpmu_delete_blog( $blog_id, true );
$this->assertEquals( false, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) );
$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' ) );
@@ -216,7 +210,6 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
// Delete the site and force a table drop.
wpmu_delete_blog( $blog_id, true );
$this->assertEquals( false, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) );
$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' ) );