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. git-svn-id: https://develop.svn.wordpress.org/trunk@42698 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4bc7afd701
commit
2e2fd97287
|
@ -234,17 +234,21 @@ function get_site_by_path( $domain, $path, $segments = null ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'domain__in' => $domains,
|
'number' => 1,
|
||||||
'path__in' => $paths,
|
|
||||||
'number' => 1,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( count( $domains ) > 1 ) {
|
if ( count( $domains ) > 1 ) {
|
||||||
|
$args['domain__in'] = $domains;
|
||||||
$args['orderby']['domain_length'] = 'DESC';
|
$args['orderby']['domain_length'] = 'DESC';
|
||||||
|
} else {
|
||||||
|
$args['domain'] = array_shift( $domains );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( count( $paths ) > 1 ) {
|
if ( count( $paths ) > 1 ) {
|
||||||
|
$args['path__in'] = $paths;
|
||||||
$args['orderby']['path_length'] = 'DESC';
|
$args['orderby']['path_length'] = 'DESC';
|
||||||
|
} else {
|
||||||
|
$args['path'] = array_shift( $paths );
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = get_sites( $args );
|
$result = get_sites( $args );
|
||||||
|
|
Loading…
Reference in New Issue