#23506 closed defect (bug) (fixed)
get_terms() assumes its taxonomies argument is a numeric array with a 0 key
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.7 | Priority: | normal |
| Severity: | normal | Version: | 3.6 |
| Component: | Taxonomy | Keywords: | has-patch commit |
| Focuses: | Cc: |
Description
In a few places in get_terms() we are using $taxonomies[0] after we've established that we have more than one taxonomy. The array isn't always 0-based, though.
For example, get_taxonomies() returns arrays with the taxonomy name as a key, which breaks this pattern.
In the attached patch, the taxonomies are run through array_values(), which gives us a 0-based array of the taxonomies.
Attachments (3)
Change History (14)
#2
@
13 years ago
- Summary changed from get_terms() assumes its taxonomies argument is 0-based to get_terms() assumes its taxonomies argument is a numeric array
Fixing ticket title to clearer terminology. Probably worth updating the patch too.
#3
follow-up:
↓ 4
@
13 years ago
I still think 0-based is the better term.
The array, which is a result of $a = array( 1, 2, 3); unset( $a[0] ); is still numeric, but its zeroth element is missing.
#4
in reply to:
↑ 3
@
13 years ago
- Summary changed from get_terms() assumes its taxonomies argument is a numeric array to get_terms() assumes its taxonomies argument is a numeric array with a 0 key
Replying to nbachiyski:
I still think 0-based is the better term.
The array, which is a result of
$a = array( 1, 2, 3); unset( $a[0] );is still numeric, but its zeroth element is missing.
True!
#5
@
13 years ago
- Milestone changed from Awaiting Review to Future Release
Seems prudent. Alternatively (or even additionally), we could start using using the proper array function to grab the first item, instead of [0] (i.e. current(), or even list()).
#7
@
13 years ago
- Keywords dev-feedback removed
- Milestone changed from Future Release to 3.7
+ whitespace in the refresh
#9
@
12 years ago
Since we're adjusting whitespace, $hierarchy[$child_of] should be $hierarchy[ $child_of ] — for some time we have put spaces here when the key is a variable.
Test in [UT1219].