Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#12344 closed defect (bug) (fixed)

wp_set_object_terms() causes php notice when WP_DEBUG is on

Reported by: jeremyclarke's profile jeremyclarke Owned by: jeremyclarke's profile jeremyclarke
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Warnings/Notices Keywords:
Focuses: Cc:

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.

Attachments (1)

11319.diff (604 bytes) - added by jeremyclarke 14 years ago.
Avoid php notices in wp_set_object_terms()

Download all attachments as: .zip

Change History (2)

@jeremyclarke
14 years ago

Avoid php notices in wp_set_object_terms()

#1 @wpmuguru
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [13321]) fix debug notice in wp_set_object_terms(), props jeremyclarke, fixes #12344

Note: See TracTickets for help on using tickets.