Changeset 40102 for trunk/src/wp-includes/class-wp-network.php
- Timestamp:
- 02/22/2017 10:41:20 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-network.php
r37919 r40102 268 268 */ 269 269 public static function get_by_path( $domain = '', $path = '', $segments = null ) { 270 global $wpdb;271 272 270 $domains = array( $domain ); 273 271 $pieces = explode( '.', $domain ); … … 296 294 $using_paths = wp_cache_get( 'networks_have_paths', 'site-options' ); 297 295 if ( false === $using_paths ) { 298 $using_paths = (int) $wpdb->get_var( "SELECT id FROM {$wpdb->site} WHERE path <> '/' LIMIT 1" ); 296 $using_paths = get_networks( array( 297 'number' => 1, 298 'count' => true, 299 'path__not_in' => '/', 300 ) ); 299 301 wp_cache_add( 'networks_have_paths', $using_paths, 'site-options' ); 300 302 } … … 354 356 } 355 357 356 // @todo Consider additional optimization routes, perhaps as an opt-in for plugins.357 // We already have paths covered. What about how far domains should be drilled down (including www)?358 359 $search_domains = "'" . implode( "', '", $wpdb->_escape( $domains ) ) . "'";360 361 358 if ( ! $using_paths ) { 362 $network = $wpdb->get_row( " 363 SELECT * FROM {$wpdb->site} 364 WHERE domain IN ({$search_domains}) 365 ORDER BY CHAR_LENGTH(domain) 366 DESC LIMIT 1 367 " ); 368 369 if ( ! empty( $network ) && ! is_wp_error( $network ) ) { 370 return new WP_Network( $network ); 359 $networks = get_networks( array( 360 'number' => 1, 361 'orderby' => array( 362 'domain_length' => 'DESC', 363 ), 364 'domain__in' => $domains, 365 ) ); 366 367 if ( ! empty( $networks ) ) { 368 return array_shift( $networks ); 371 369 } 372 370 373 371 return false; 374 375 } else { 376 $search_paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'";377 $networks = $wpdb->get_results( "378 SELECT * FROM {$wpdb->site}379 WHERE domain IN ({$search_domains})380 AND path IN ({$search_paths})381 ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC382 " );383 }372 } 373 374 $networks = get_networks( array( 375 'orderby' => array( 376 'domain_length' => 'DESC', 377 'path_length' => 'DESC', 378 ), 379 'domain__in' => $domains, 380 'path__in' => $paths, 381 ) ); 384 382 385 383 /* … … 403 401 404 402 if ( true === $found ) { 405 return new WP_Network( $network );403 return $network; 406 404 } 407 405
Note: See TracChangeset
for help on using the changeset viewer.