#23506 closed defect (bug) (fixed)
get_terms() assumes its taxonomies argument is a numeric array with a 0 key
| Reported by: | nbachiyski | Owned by: | wonderboymusic |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.7 |
| Component: | Taxonomy | Version: | 3.6 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | Focuses: |
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
@
14 years ago
- Summary get_terms() assumes its taxonomies argument is 0-based → 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
@
14 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
@
14 years ago
- Summary get_terms() assumes its taxonomies argument is a numeric array → 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 Awaiting Review → 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 Future Release → 3.7
+ whitespace in the refresh
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Test in [UT1219].