WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#22479 closed defect (bug) (fixed)

Undefined Variable in `mt_setPostCategories()`

Reported by: ericmann Owned by: ryan
Milestone: 3.5 Priority: normal
Severity: minor Version: 3.4.2
Component: XML-RPC Keywords: has-patch commit
Focuses: Cc:

Description

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.

Attachments (1)

mt_setPostCategories.diff (484 bytes) - added by ericmann 9 years ago.
Explicitly define the $catids array before trying to manipulate it.

Download all attachments as: .zip

Change History (5)

@ericmann
9 years ago

Explicitly define the $catids array before trying to manipulate it.

#1 @SergeyBiryukov
9 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 3.5

#2 follow-up: @markoheijnen
9 years ago

I had once added on a XML-RPC ticket a fix a lot of notices for non wp.* methods ( #20394 ). Didn't fix this one.
Curious what the policy is for it since then it didn't made it.

#3 in reply to: ↑ 2 @ericmann
9 years ago

Replying to markoheijnen:

I had once added on a XML-RPC ticket a fix a lot of notices for non wp.* methods ( #20394 ). Didn't fix this one.
Curious what the policy is for it since then it didn't made it.

I'm not sure. All I can say for certain is that this bug does in fact break the current version of Windows Live Writer (I was using it to test something else entirely when I can across the issue).

#4 @ryan
9 years ago

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

In 22622:

Define array to avoid notice.

Props ericmann
fixes #22479

Note: See TracTickets for help on using tickets.