Opened 14 years ago
Closed 12 years ago
#16310 closed defect (bug) (fixed)
get_taxonomy_labels() and _get_custom_object_labels() fail if $object->taxonomy is not array
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | Cc: |
Description
$object->labels is always stdObject on the taxonomy objects created by WordPress, but the get_taxonomy_labels() and _get_custom_object_labels() functions expect it to be an array and will fail otherwise.
Casting to array works fine as the functions already convert back to stdObject when they're finished.
Attachments (2)
Change History (15)
#3
@
14 years ago
Sounds like you're using these functions manually, rather than letting WP call it during post type registration. Some of them are already marked private, perhaps the rest should be.
#4
follow-up:
↓ 5
@
14 years ago
This will throw a fatal "cannot use object of type stdClass as array" error at line 1174 of wp-includes/post.php:
$tax = get_taxonomy('category'); $labels = get_taxonomy_labels($tax);
nacin: That makes sense for _get_custom_object_labels() but get_taxonomy_labels() is a public API function.
Hope this helps.
#5
in reply to:
↑ 4
@
14 years ago
Replying to foofy:
nacin: That makes sense for _get_custom_object_labels() but get_taxonomy_labels() is a public API function.
It shouldn't be. You should do this instead:
$tax = get_taxonomy('category'); $labels = $tax->labels;
#6
@
14 years ago
That makes sense. I feel that casting to array would avoid confusion later, though.
#8
@
14 years ago
Don't think that's entirely worth the effort. I'm just not sure why they were implicitly public functions to begin with.
I'm warming up to the initial patch here though.
Casts $object->labels to array as it's what the functions expect it to be