Make WordPress Core


Ignore:
Timestamp:
09/20/2022 02:24:08 PM (3 years ago)
Author:
spacedmonkey
Message:

Networks and Sites: Store main site id of a network in network options.

Instead of caching main site id an object cache, store main site id on a network options. This results in less database queries on sites without persistent object caching.

Props spacedmonkey, johnjamesjacoby, peterwilsoncc, desrosj.
Fixes #55802.

File:
1 edited

Legend:

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

    r51860 r54256  
    9090
    9191        /**
     92         * @ticket 55802
     93         */
     94        public function test_get_main_site_id_with_different_network_cache_id() {
     95            $this->assertSame( self::$site_ids['wordpress.org/'], get_main_site_id( self::$network_ids['wordpress.org/'] ), 'Main blog id needs to match blog id of wordpress.org/' );
     96            $this->assertSame( self::$site_ids['wordpress.org/'], (int) get_network_option( self::$network_ids['wordpress.org/'], 'main_site' ), 'Network option needs to match blog id of wordpress.org/' );
     97
     98            $this->assertSame( 0, get_main_site_id( self::$network_ids['wp.org/'] ), 'Main blog id should not be found' );
     99            $this->assertSame( 0, (int) get_network_option( self::$network_ids['wp.org/'], 'main_site' ), 'Network option should not be found' );
     100        }
     101
     102        /**
    92103         * @ticket 29684
    93104         */
Note: See TracChangeset for help on using the changeset viewer.