Opened 3 years ago
Closed 3 years ago
#12344 closed defect (bug) (fixed)
wp_set_object_terms() causes php notice when WP_DEBUG is on
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | Warnings/Notices | Version: | 3.0 |
| Severity: | normal | Keywords: | |
| Cc: | jeremyclarke |
Description
Super simple problem. When WP_DEBUG is set to true and the $append argument is set to true in wp_set_object_terms() a PHP notice is output that can kill a post form submission.
The culprit is a do_action call at the bottom of the function that presumes that $old_tt_ids has been set, even though currently $old_tt_ids is only set if $append == false (the default).
do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids);
My solution is simply to define $old_tt_ids as an array before the initial definition happens similar to how $tt_ids and $term_ids are defined as blank arrays at the start. I also reorganized the three definitions a bit so that they are all in the same place at the top of the function.

Avoid php notices in wp_set_object_terms()