mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Don't force distinct term queries when specifying number and object_ids.
This reverts [41377], which caused performance problems on sites with a large number of terms. See #41796. git-svn-id: https://develop.svn.wordpress.org/trunk@41880 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -471,61 +471,4 @@ class Tests_Term_Query extends WP_UnitTestCase {
|
||||
$this->assertSame( $expected, $found2 );
|
||||
$this->assertSame( $expected, $found3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 41796
|
||||
*/
|
||||
public function test_number_should_work_with_object_ids() {
|
||||
register_taxonomy( 'wptests_tax', 'post' );
|
||||
|
||||
$term_1 = self::factory()->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
) );
|
||||
$term_2 = self::factory()->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
) );
|
||||
|
||||
$post_1 = self::factory()->post->create();
|
||||
$post_2 = self::factory()->post->create();
|
||||
|
||||
wp_set_object_terms( $post_1, array( $term_1, $term_2 ), 'wptests_tax' );
|
||||
wp_set_object_terms( $post_2, array( $term_1 ), 'wptests_tax' );
|
||||
|
||||
$q = new WP_Term_Query( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'object_ids' => array( $post_1, $post_2 ),
|
||||
'number' => 2,
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $term_1, $term_2 ), wp_list_pluck( $q->terms, 'term_id' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 41796
|
||||
*/
|
||||
public function test_number_should_work_with_object_ids_and_all_with_object_id() {
|
||||
register_taxonomy( 'wptests_tax', 'post' );
|
||||
|
||||
$term_1 = self::factory()->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
) );
|
||||
$term_2 = self::factory()->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
) );
|
||||
|
||||
$post_1 = self::factory()->post->create();
|
||||
$post_2 = self::factory()->post->create();
|
||||
|
||||
wp_set_object_terms( $post_1, array( $term_1, $term_2 ), 'wptests_tax' );
|
||||
wp_set_object_terms( $post_2, array( $term_1 ), 'wptests_tax' );
|
||||
|
||||
$q = new WP_Term_Query( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'object_ids' => array( $post_1, $post_2 ),
|
||||
'fields' => 'all_with_object_id',
|
||||
'number' => 2,
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $term_1, $term_1 ), wp_list_pluck( $q->terms, 'term_id' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user