Ticket #40362: 40362.patch
File 40362.patch, 4.5 KB (added by , 7 years ago) |
---|
-
src/wp-includes/ms-blogs.php
462 462 wp_cache_delete( $blog_id, 'blog-details' ); 463 463 wp_cache_delete( $blog_id . 'short' , 'blog-details' ); 464 464 wp_cache_delete( $domain_path_key, 'blog-lookup' ); 465 wp_cache_delete( $domain_path_key, 'blog-id-cache' );466 465 wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' ); 467 466 wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' ); 468 467 -
src/wp-includes/ms-functions.php
307 307 function get_blog_id_from_url( $domain, $path = '/' ) { 308 308 $domain = strtolower( $domain ); 309 309 $path = strtolower( $path ); 310 $id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );311 312 if ( $id == -1 ) // blog does not exist313 return 0;314 elseif ( $id )315 return (int) $id;316 310 317 311 $args = array( 318 312 'domain' => $domain, 319 313 'path' => $path, 320 314 'fields' => 'ids', 315 'number' => 1, 321 316 ); 322 317 $result = get_sites( $args ); 323 318 $id = array_shift( $result ); 324 319 325 320 if ( ! $id ) { 326 wp_cache_set( md5( $domain . $path ), -1, 'blog-id-cache' );327 321 return 0; 328 322 } 329 323 330 wp_cache_set( md5( $domain . $path ), $id, 'blog-id-cache' );331 332 324 return $id; 333 325 } 334 326 -
tests/phpunit/tests/multisite/site.php
163 163 $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) ); 164 164 $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) ); 165 165 $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) ); 166 $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );167 166 } 168 167 169 168 /** … … 191 190 */ 192 191 function test_data_in_cache_after_wpmu_delete_blog_drop_true() { 193 192 $blog_id = self::factory()->blog->create(); 194 193 195 194 $details = get_blog_details( $blog_id, false ); 196 195 $key = md5( $details->domain . $details->path ); 197 198 196 // Delete the site and force a table drop. 199 197 wpmu_delete_blog( $blog_id, true ); 200 198 201 199 $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) ); 202 200 $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) ); 203 201 $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) ); 204 $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );205 202 } 206 203 207 204 /** … … 239 236 $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) ); 240 237 $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) ); 241 238 $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) ); 242 $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );243 239 } 244 240 245 241 /** … … 627 623 function test_get_blog_id_from_url() { 628 624 $blog_id = self::factory()->blog->create(); 629 625 $details = get_site( $blog_id ); 630 $key = md5( $details->domain . $details->path );631 626 632 627 // Test the original response and cached response for the newly created site. 633 628 $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); 634 $this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );635 629 } 636 630 637 631 /** … … 652 646 $details = get_site( $blog_id ); 653 647 654 648 $this->assertEquals( 0, get_blog_id_from_url( $details->domain, 'foo' ) ); 655 $this->assertEquals( -1, wp_cache_get( md5( $details->domain . 'foo' ), 'blog-id-cache' ) );656 649 } 657 650 658 651 /** … … 662 655 function test_get_blog_id_from_url_with_deleted_flag() { 663 656 $blog_id = self::factory()->blog->create(); 664 657 $details = get_site( $blog_id ); 665 $key = md5( $details->domain . $details->path );666 658 wpmu_delete_blog( $blog_id ); 667 659 668 660 $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); 669 $this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );670 661 } 671 662 672 663 /** … … 676 667 function test_get_blog_id_from_url_after_dropped() { 677 668 $blog_id = self::factory()->blog->create(); 678 669 $details = get_site( $blog_id ); 679 $key = md5( $details->domain . $details->path );680 670 wpmu_delete_blog( $blog_id, true ); 681 671 682 $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );683 672 $this->assertEquals( 0, get_blog_id_from_url( $details->domain, $details->path ) ); 684 $this->assertEquals( -1, wp_cache_get( $key, 'blog-id-cache' ) );685 673 } 686 674 687 675 /**