From f9877147f6504c6eb90f9ca29c3756ed31dc988e Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 12 Sep 2013 05:08:33 +0000 Subject: [PATCH] Use `reset()` to access the first element of an array, don't assume there is an item at index `0`. See #25282. git-svn-id: https://develop.svn.wordpress.org/trunk@25384 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/taxonomy.php | 2 +- tests/phpunit/tests/term/getTerms.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index fe2bee4430..44d9dfb476 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -1238,7 +1238,7 @@ function get_terms($taxonomies, $args = '') { $args = wp_parse_args( $args, $defaults ); $args['number'] = absint( $args['number'] ); $args['offset'] = absint( $args['offset'] ); - if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) || + if ( !$single_taxonomy || ! is_taxonomy_hierarchical( reset( $taxonomies ) ) || '' !== $args['parent'] ) { $args['child_of'] = 0; $args['hierarchical'] = false; diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php index 05f771f70c..eb576e659a 100644 --- a/tests/phpunit/tests/term/getTerms.php +++ b/tests/phpunit/tests/term/getTerms.php @@ -85,7 +85,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { function test_get_terms_should_allow_arbitrary_indexed_taxonomies_array() { $term_id = $this->factory->tag->create(); $terms = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) ); - $this->assertEquals( $term_id, $terms[0]->term_id ); + $this->assertEquals( $term_id, reset( $terms )->term_id ); } /**