Networks and Sites: In `get_site_by_path()`, use single `domain` and `path` parameters if there's only one item to look for.
This should increase the chances of `WP_Site_Query::get_sites()` hitting an existing cache. Props spacedmonkey. Fixes #42299. Built from https://develop.svn.wordpress.org/trunk@42698 git-svn-id: http://core.svn.wordpress.org/trunk@42526 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f88dddcab5
commit
4a55ea5e68
|
@ -234,17 +234,21 @@ function get_site_by_path( $domain, $path, $segments = null ) {
|
|||
}
|
||||
|
||||
$args = array(
|
||||
'domain__in' => $domains,
|
||||
'path__in' => $paths,
|
||||
'number' => 1,
|
||||
);
|
||||
|
||||
if ( count( $domains ) > 1 ) {
|
||||
$args['domain__in'] = $domains;
|
||||
$args['orderby']['domain_length'] = 'DESC';
|
||||
} else {
|
||||
$args['domain'] = array_shift( $domains );
|
||||
}
|
||||
|
||||
if ( count( $paths ) > 1 ) {
|
||||
$args['path__in'] = $paths;
|
||||
$args['orderby']['path_length'] = 'DESC';
|
||||
} else {
|
||||
$args['path'] = array_shift( $paths );
|
||||
}
|
||||
|
||||
$result = get_sites( $args );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-42697';
|
||||
$wp_version = '5.0-alpha-42698';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue