WordPress.org

Make WordPress Core

Opened 8 months ago

Last modified 8 weeks ago

#25037 assigned defect (bug)

XML-RPC : Can't remove all the categories from a post by using metaWeblog.editPost

Reported by: daniloercoli Owned by: markoheijnen
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.6
Component: XML-RPC Keywords: mobile
Focuses: Cc:

Description

Seems that you can't remove all the categories from a post by calling mw_editPost.
I tried both passing an empty array, or skipping the entry 'categories', in the content struct, but none of them worked. The post still has the previous categories attached to it.

Change History (7)

comment:1 SergeyBiryukov8 months ago

  • Component changed from General to XML-RPC

comment:2 nacin8 months ago

Posts must have at least one category (this is "soft" in core but may be strictly enforced in XML-RPC) — attempting to remove *all* categories without leaving one may be the issue.

comment:3 SergeyBiryukov8 months ago

This is consistent with how wp_update_post() works.

mw_editPost() fills in $post_category array (line 4507), then passes it to wp_update_post() (line 4571). wp_update_post() only overwrites existing post categories if the passed array is not empty: tags/3.6/wp-includes/post.php#L2919.

comment:4 follow-up: redsweater8 months ago

FWIW removing "all" categories for a post works when using mt.setPostCategories, providing an empty array.

nacin's comment about it always being required that there is one category seems to be true, when I remove all categories using this technique, the post acquires the single category "Uncategorized" (default category?) as a result.

comment:5 in reply to: ↑ 4 daniloercoli8 months ago

Replying to redsweater:

nacin's comment about it always being required that there is one category seems to be true, when I remove all categories using this technique, the post acquires the single category "Uncategorized" (default category?) as a result.

Yes, that's what I was expecting when removing "all" categories for a post.

comment:6 markoheijnen8 months ago

  • Owner set to markoheijnen
  • Status changed from new to assigned
Note: See TracTickets for help on using tickets.