WordPress.org

Make WordPress Core

Changeset 42698


Ignore:
Timestamp:
02/11/2018 05:08:58 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-load.php

    r42343 r42698  
    235235
    236236    $args = array(
    237         'domain__in' => $domains,
    238         'path__in'   => $paths,
    239         'number'     => 1,
     237        'number' => 1,
    240238    );
    241239
    242240    if ( count( $domains ) > 1 ) {
     241        $args['domain__in']               = $domains;
    243242        $args['orderby']['domain_length'] = 'DESC';
     243    } else {
     244        $args['domain'] = array_shift( $domains );
    244245    }
    245246
    246247    if ( count( $paths ) > 1 ) {
     248        $args['path__in']               = $paths;
    247249        $args['orderby']['path_length'] = 'DESC';
     250    } else {
     251        $args['path'] = array_shift( $paths );
    248252    }
    249253
Note: See TracChangeset for help on using the changeset viewer.