Make WordPress Core

Opened 11 years ago

Last modified 6 years ago

#25037 assigned defect (bug)

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

Reported by: daniloercoli's profile daniloercoli Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6
Component: XML-RPC Keywords: needs-patch
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 (8)

#1 @SergeyBiryukov
11 years ago

  • Component changed from General to XML-RPC

#2 @nacin
11 years 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.

#3 @SergeyBiryukov
11 years 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.

#4 follow-up: @redsweater
11 years 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.

#5 in reply to: ↑ 4 @daniloercoli
11 years 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.

#6 @markoheijnen
11 years ago

  • Owner set to markoheijnen
  • Status changed from new to assigned

#8 @wonderboymusic
9 years ago

  • Keywords needs-patch added; mobile removed
  • Owner markoheijnen deleted

Anyone can patch this

Note: See TracTickets for help on using tickets.