Skip to content

Commit 3d7f52a

Browse files
committed
Fix potential back-compat break for passing false as object_ids
1 parent 34b3bc7 commit 3d7f52a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/wp-includes/class-wp-term-query.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,11 @@ public function get_terms() {
590590
);
591591
}
592592

593-
if ( empty( $args['object_ids'] ) && ! is_numeric( $args['object_ids'] ) ) {
594-
$args['object_ids'] = array();
595-
} else {
596-
$args['object_ids'] = array_map( 'intval', (array) $args['object_ids'] );
593+
if ( null !== $args['object_ids'] ) {
594+
$args['object_ids'] = array_map(
595+
'intval',
596+
(array) $args['object_ids']
597+
);
597598
}
598599

599600
if ( ! empty( $args['object_ids'] ) ) {

tests/phpunit/tests/term/query.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public function test_object_ids_null_should_return_all_terms() {
477477
public function test_object_ids_false_should_return_all_terms() {
478478
register_taxonomy( 'wptests_tax_1', 'post' );
479479

480-
$terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax_1' ) );
480+
self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax_1' ) );
481481

482482
$query = new WP_Term_Query(
483483
array(
@@ -488,7 +488,7 @@ public function test_object_ids_false_should_return_all_terms() {
488488
)
489489
);
490490

491-
$this->assertSameSets( $terms, $query->terms, 'When object_ids is false, all terms should be returned without filtering.' );
491+
$this->assertSame( array(), $query->terms, 'When object_ids is false, all terms should be returned without filtering.' );
492492
}
493493

494494
/**

0 commit comments

Comments
 (0)