[wp-trac] [WordPress Trac] #47415: is_network_admin() is not checking if the context install is a multisite - documentation improvement
WordPress Trac
noreply at wordpress.org
Sun Jun 30 05:19:13 UTC 2019
#47415: is_network_admin() is not checking if the context install is a multisite -
documentation improvement
-------------------------------------------------+-------------------------
Reporter: svovaf | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future
| Release
Component: Networks and Sites | Version:
Severity: minor | Resolution:
Keywords: good-first-bug has-patch needs- | Focuses: docs,
refresh | multisite
-------------------------------------------------+-------------------------
Comment (by svovaf):
Starting from WP 5.2, where the error catch mechanism was introduced, we
have started to receive complaints about `get_blog_list()` as a non-
defined function:
> Fatal error: Uncaught Error: Call to undefined function get_blog_list()
After troubleshooting a few live sites that encountered the issue we found
that something in core's background logic (could be the updates mechanism
or some WP Cron) is triggering a call to the network-level path, even
though the sites were not set to work as a multi-site network. Since some
of our code's logic assumed that `is_network_admin()` can only return
`true` when running within a network environment, the following logic
eventually have fallen back to use `get_blog_list()` which like the rest
of the network functions are not defined as `ms-blogs.php` and `ms-
deprecated.php` aren't included into the execution sequence on a non-
network environment:
{{{#!php
<?php
if ( function_exists( 'get_sites' ) ) {
// For WP 4.6 and above.
return get_sites( $args );
} else if ( function_exists( 'wp_get_sites' ) ) {
// For WP 3.7 to WP 4.5.
return wp_get_sites( $args );
} else {
// For WP 3.6 and below.
return get_blog_list( 0, 'all' );
}
}}}
Hope it helps.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47415#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list