Ticket #40196: 40196.patch
File 40196.patch, 4.5 KB (added by , 8 years ago) |
---|
-
src/wp-includes/class-wp-site-query.php
99 99 * Sets up the site query, based on the query vars passed. 100 100 * 101 101 * @since 4.6.0 102 * @since 4.8.0 Introduced 'lang_id' parameter. 102 103 * @access public 103 104 * 104 105 * @param string|array $query { … … 138 139 * @type int $mature Limit results to mature sites. Accepts '1' or '0'. Default empty. 139 140 * @type int $spam Limit results to spam sites. Accepts '1' or '0'. Default empty. 140 141 * @type int $deleted Limit results to deleted sites. Accepts '1' or '0'. Default empty. 142 * @type int $lang_id Limit results to a language ID. Default empty. 141 143 * @type string $search Search term(s) to retrieve matching sites for. Default empty. 142 144 * @type array $search_columns Array of column names to be searched. Accepts 'domain' and 'path'. 143 145 * Default empty array. … … 169 171 'mature' => null, 170 172 'spam' => null, 171 173 'deleted' => null, 174 'lang_id' => null, 172 175 'search' => '', 173 176 'search_columns' => array(), 174 177 'count' => false, … … 471 474 $this->sql_clauses['where']['public'] = $wpdb->prepare( "public = %d ", $public ); 472 475 } 473 476 477 if ( is_numeric( $this->query_vars['lang_id'] ) ) { 478 $lang_id = absint( $this->query_vars['lang_id'] ); 479 $this->sql_clauses['where']['lang_id'] = $wpdb->prepare( "lang_id = %d ", $lang_id ); 480 } 481 474 482 // Falsey search strings are ignored. 475 483 if ( strlen( $this->query_vars['search'] ) ) { 476 484 $search_columns = array(); -
src/wp-includes/ms-blogs.php
556 556 * Retrieves a list of sites matching requested arguments. 557 557 * 558 558 * @since 4.6.0 559 * @since 4.8.0 Introduced 'lang_id' parameter. 559 560 * 560 561 * @see WP_Site_Query::parse_query() 561 562 * … … 596 597 * @type int $mature Limit results to mature sites. Accepts '1' or '0'. Default empty. 597 598 * @type int $spam Limit results to spam sites. Accepts '1' or '0'. Default empty. 598 599 * @type int $deleted Limit results to deleted sites. Accepts '1' or '0'. Default empty. 600 * @type int $lang_id Limit results to a language ID. Default empty. 599 601 * @type string $search Search term(s) to retrieve matching sites for. Default empty. 600 602 * @type array $search_columns Array of column names to be searched. Accepts 'domain' and 'path'. 601 603 * Default empty array. -
tests/phpunit/tests/multisite/siteQuery.php
431 431 $this->assertEqualSets( array_values( self::$site_ids ), $found ); 432 432 } 433 433 434 public function test_wp_site_query_by_lang_id_with_zero() { 435 $q = new WP_Site_Query(); 436 $found = $q->query( array( 437 'fields' => 'ids', 438 // Exclude main site since we don't have control over it here. 439 'site__not_in' => array( 1 ), 440 'lang_id' => 0, 441 ) ); 442 443 $this->assertEqualSets( array_values( self::$site_ids ), $found ); 444 } 445 446 public function test_wp_site_query_by_lang_id() { 447 update_blog_details( 448 self::$site_ids['www.w.org/make/'], 449 array( 450 'lang_id' => 1, 451 ) 452 ); 453 454 $q = new WP_Site_Query(); 455 $found = $q->query( array( 456 'fields' => 'ids', 457 'lang_id' => 1, 458 ) ); 459 460 update_blog_details( 461 self::$site_ids['www.w.org/make/'], 462 array( 463 'lang_id' => 0, 464 ) 465 ); 466 467 $expected = array( 468 self::$site_ids['www.w.org/make/'], 469 ); 470 471 $this->assertEqualSets( $expected, $found ); 472 } 473 474 public function test_wp_site_query_by_lang_id_with_no_results() { 475 $q = new WP_Site_Query(); 476 $found = $q->query( array( 477 'fields' => 'ids', 478 'lang_id' => 2, 479 ) ); 480 481 $this->assertEmpty( $found ); 482 } 483 434 484 public function test_wp_site_query_by_search_with_text_in_domain() { 435 485 $q = new WP_Site_Query(); 436 486 $found = $q->query( array(