[wp-trac] [WordPress Trac] #58185: Lazy load site meta

WordPress Trac noreply at wordpress.org
Mon May 15 02:53:15 UTC 2023


#58185: Lazy load site meta
---------------------------------------------+-----------------------------
 Reporter:  spacedmonkey                     |       Owner:  spacedmonkey
     Type:  enhancement                      |      Status:  reopened
 Priority:  normal                           |   Milestone:  6.3
Component:  Networks and Sites               |     Version:  5.1
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  multisite,
                                             |  performance
---------------------------------------------+-----------------------------
Changes (by dd32):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 [55747] caused an issue on WordPress.org, we were using `get_sites()`
 within `sunrise.php` which no longer works with this change.

 {{{
 ( ! ) Fatal error: Uncaught Error: Class 'WP_Metadata_Lazyloader' not
 found in wp-includes/meta.php on line 1217
 }}}

 The metadata lazyloader is included much later than sunrise:
 https://core.trac.wordpress.org/browser/trunk/src/wp-
 settings.php?marks=140-141,191#L136



 Changing it to the following does resolve it though.
 {{{
 $sites = get_sites( [
    ...
    'update_site_meta_cache' => false,
 ] );
 }}}

 @spacedmonkey what's your thoughts here? I somewhat feel like running
 `get_sites()` within sunrise is maybe an intended thing to be able to do.
 Unfortunately a simple `function_exists()` is not viable here as the
 functions are loaded, it's just the classes that aren't, and I think the
 classes can be filtered?

 Full stack trace:
 {{{
 ( ! ) Error: Class 'WP_Metadata_Lazyloader' not found in wp-
 includes/meta.php on line 1217
 Call Stack
 #       Time    Memory  Function        Location
 1       0.0001  368304  {main}( )       .../index.php:0
 2       0.0001  368584  require( 'wp-blog-header.php )  .../index.php:18
 3       0.0001  369192  require_once( 'wp-load.php )    .../wp-blog-
 header.php:13
 4       0.0002  369984  require_once( 'wp-config.php )  .../wp-load.php:50
 5       0.0008  403768  require_once( 'wp-settings.php )        .../wp-
 config.php:124
 6       0.0094  1297488 require( 'wp-includes/ms-settings.php ) .../wp-
 settings.php:141
 # Sunrise here, some filters added.
 7       0.0102  1309120 ms_load_current_site_and_network( $domain =
 'test.wordpress.org', $path = '/plugins/hello-dolly/', $subdomain = TRUE )
 .../ms-settings.php:72
 8       0.0102  1309120 get_site_by_path( $domain = 'test.wordpress.org',
 $path = '/plugins/hello-dolly/', $segments = 1 )      .../ms-load.php:366
 9       0.0102  1309944 apply_filters( $hook_name =
 'pre_get_site_by_path', $value = NULL, ...$args =
 variadic('test.wordpress.org', '/plugins/hello-dolly/', 1, [0 =>
 '/plugins/', 1 => '/']) )        .../ms-load.php:212
 10      0.0102  1310728 WP_Hook->apply_filters( $value = NULL, $args = [0
 => NULL, 1 => 'test.wordpress.org', 2 => '/plugins/hello-dolly/', 3 => 1,
 4 => [0 => '/plugins/', 1 => '/']] )        .../plugin.php:205
 11      0.0103  1312232 wporg_sites_on_rosetta_domains( $site = NULL,
 $domain = 'test.wordpress.org', $path = '/plugins/hello-dolly/', $segments
 = 1 )  .../class-wp-hook.php:312
 12      0.0103  1312608 wporg_get_locale_site( $domain =
 'test.wordpress.org', $path = ??? )    .../sunrise.php:134
 13      0.0103  1312984 get_sites( $args = ['network_id' => 6, 'number' =>
 1, 'domain' => 'test.wordpress.org', 'path' => '/'] )
 .../sunrise.php:36
 14      0.0103  1313208 WP_Site_Query->query( $query = ['network_id' => 6,
 'number' => 1, 'domain' => 'test.wordpress.org', 'path' => '/'] )
 .../ms-site.php:446
 15      0.0103  1313208 WP_Site_Query->get_sites( )     .../class-wp-site-
 query.php:272
 16      0.0112  1325664 wp_lazyload_site_meta( $site_ids = [0 => 161] )
 .../class-wp-site-query.php:392
 17      0.0112  1325664 wp_metadata_lazyloader( )       .../ms-
 site.php:377
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58185#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list