WordPress.org

Make WordPress Core

Ticket #40362: 40362.patch

File 40362.patch, 4.5 KB (added by spacedmonkey, 4 years ago)
  • src/wp-includes/ms-blogs.php

     
    462462        wp_cache_delete( $blog_id, 'blog-details' );
    463463        wp_cache_delete( $blog_id . 'short' , 'blog-details' );
    464464        wp_cache_delete( $domain_path_key, 'blog-lookup' );
    465         wp_cache_delete( $domain_path_key, 'blog-id-cache' );
    466465        wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' );
    467466        wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' );
    468467
  • src/wp-includes/ms-functions.php

     
    307307function get_blog_id_from_url( $domain, $path = '/' ) {
    308308        $domain = strtolower( $domain );
    309309        $path = strtolower( $path );
    310         $id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
    311 
    312         if ( $id == -1 ) // blog does not exist
    313                 return 0;
    314         elseif ( $id )
    315                 return (int) $id;
    316310
    317311        $args = array(
    318312                'domain' => $domain,
    319313                'path' => $path,
    320314                'fields' => 'ids',
     315                'number' => 1,
    321316        );
    322317        $result = get_sites( $args );
    323318        $id = array_shift( $result );
    324319
    325320        if ( ! $id ) {
    326                 wp_cache_set( md5( $domain . $path ), -1, 'blog-id-cache' );
    327321                return 0;
    328322        }
    329323
    330         wp_cache_set( md5( $domain . $path ), $id, 'blog-id-cache' );
    331 
    332324        return $id;
    333325}
    334326
  • tests/phpunit/tests/multisite/site.php

     
    163163                $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
    164164                $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
    165165                $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
    166                 $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
    167166        }
    168167
    169168        /**
     
    191190         */
    192191        function test_data_in_cache_after_wpmu_delete_blog_drop_true() {
    193192                $blog_id = self::factory()->blog->create();
    194 
     193               
    195194                $details = get_blog_details( $blog_id, false );
    196195                $key = md5( $details->domain . $details->path );
    197 
    198196                // Delete the site and force a table drop.
    199197                wpmu_delete_blog( $blog_id, true );
    200198
    201199                $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
    202200                $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
    203201                $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
    204                 $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
    205202        }
    206203
    207204        /**
     
    239236                $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
    240237                $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
    241238                $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
    242                 $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
    243239        }
    244240
    245241        /**
     
    627623        function test_get_blog_id_from_url() {
    628624                $blog_id = self::factory()->blog->create();
    629625                $details = get_site( $blog_id );
    630                 $key = md5( $details->domain . $details->path );
    631626
    632627                // Test the original response and cached response for the newly created site.
    633628                $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' ) );
    635629        }
    636630
    637631        /**
     
    652646                $details = get_site( $blog_id );
    653647
    654648                $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' ) );
    656649        }
    657650
    658651        /**
     
    662655        function test_get_blog_id_from_url_with_deleted_flag() {
    663656                $blog_id = self::factory()->blog->create();
    664657                $details = get_site( $blog_id );
    665                 $key = md5( $details->domain . $details->path );
    666658                wpmu_delete_blog( $blog_id );
    667659
    668660                $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' ) );
    670661        }
    671662
    672663        /**
     
    676667        function test_get_blog_id_from_url_after_dropped() {
    677668                $blog_id = self::factory()->blog->create();
    678669                $details = get_site( $blog_id );
    679                 $key = md5( $details->domain . $details->path );
    680670                wpmu_delete_blog( $blog_id, true );
    681671
    682                 $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
    683672                $this->assertEquals( 0, get_blog_id_from_url( $details->domain, $details->path ) );
    684                 $this->assertEquals( -1, wp_cache_get( $key, 'blog-id-cache' ) );
    685673        }
    686674
    687675        /**