WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/03/2017 07:40:01 PM (2 years ago)
Author:
flixos90
Message:

Multisite: Improve get_blog_details() by using get_site_by().

get_site_by() is now the preferred way to retrieve a site object by lookup for identifying data. By using a coherent structure and get_sites() internally, it has several advantages over the direct database queries and complex code in get_blog_details(). Therefore get_blog_details() is now a wrapper for get_site_by(), providing backward compatibility fixes where necessary.

Unit tests have been adjusted to account for the blog-details and blog-lookup cache groups, which are no longer needed.

Props spacedmonkey, jeremyfelt, flixos90.
Fixes #40228.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/siteDetails.php

    r40478 r41719  
    3333     * @ticket 40063
    3434     */
    35     public function test_update_whitelisted_option_deletes_blog_details_cache( $whitelisted_option, $temporary_value ) {
    36         $blog_details = get_blog_details();
    37 
    38         $original_value = $blog_details->$whitelisted_option;
    39         update_option( $whitelisted_option, $temporary_value );
    40 
    41         $cached_result = wp_cache_get( $blog_details->id, 'blog-details' );
    42 
    43         /* Reset to original value. */
    44         update_option( $whitelisted_option, $original_value );
    45 
    46         $this->assertFalse( $cached_result );
    47     }
    48 
    49     /**
    50      * @dataProvider data_whitelisted_options
    51      *
    52      * @ticket 40063
    53      */
    5435    public function test_update_whitelisted_option_does_not_delete_site_cache( $whitelisted_option, $temporary_value ) {
    5536        $site = get_site();
     
    5940
    6041        $cached_result = wp_cache_get( $site->id, 'sites' );
    61 
    62         /* Reset to original value. */
    63         update_option( $whitelisted_option, $original_value );
    64 
    65         $this->assertNotFalse( $cached_result );
    66     }
    67 
    68     /**
    69      * @dataProvider data_whitelisted_options
    70      *
    71      * @ticket 40063
    72      */
    73     public function test_update_whitelisted_option_does_not_delete_short_blog_details_cache( $whitelisted_option, $temporary_value ) {
    74         $blog_details = get_blog_details( null, false );
    75 
    76         $original_value = get_option( $whitelisted_option );
    77         update_option( $whitelisted_option, $temporary_value );
    78 
    79         $cached_result = wp_cache_get( $blog_details->id . 'short', 'blog-details' );
    8042
    8143        /* Reset to original value. */
Note: See TracChangeset for help on using the changeset viewer.