[wp-trac] [WordPress Trac] #22479: Undefined Variable in `mt_setPostCategories()`

WordPress Trac noreply at wordpress.org
Fri Nov 16 20:48:25 UTC 2012


#22479: Undefined Variable in `mt_setPostCategories()`
-----------------------------+--------------------------
 Reporter:  ericmann         |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  XML-RPC
  Version:  3.4.2            |   Severity:  minor
 Keywords:  has-patch        |
-----------------------------+--------------------------
 This will likely only ever come up if `WP_DEBUG` is set to true, but we're
 attempting to add elements to an array inside a `foreach` without first
 creating the array.  We then pass a potentially non-existent object along
 to `wp_set_post_categories()`.

 This creates a PHP notice that, if `WP_DEBUG` is turned on with the
 server, breaks the document returned to XML-RPC clients attempting to use
 `mt.setPostCategories` to update categories.

 The fix is simple.  Just create an empty array before trying to add
 elements to it or passing it out of the function.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22479>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list