From 4a55ea5e68477f8983f60ae102db17e8e1208eb2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 11 Feb 2018 17:09:31 +0000 Subject: [PATCH] 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 --- wp-includes/ms-load.php | 10 +++++++--- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php index f2f53203ea..932ae76ca5 100644 --- a/wp-includes/ms-load.php +++ b/wp-includes/ms-load.php @@ -234,17 +234,21 @@ function get_site_by_path( $domain, $path, $segments = null ) { } $args = array( - 'domain__in' => $domains, - 'path__in' => $paths, - 'number' => 1, + '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 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 8cfb79c865..5d5db51707 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.