Opened 11 years ago
Closed 11 years ago
#26686 closed defect (bug) (fixed)
XMLRPC call will not remove all terms in a taxonomy when passed an empty array
Reported by: | jstraitiff | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | normal | Version: | 3.4 |
Component: | XML-RPC | Keywords: | has-patch |
Focuses: | Cc: |
Description
When calling wp.editPost from XMLRPC, if you pass an empty array for a set of terms it will not remove all the terms in that taxonomy for a post. If the array has even one term id in it, it will set it properly, but empty arrays get ignored and thus don't change the current terms.
I found and fixed the issue and have attached a patch. I'm adding one line in _insert_post (in wp-includes/class-wp-xmlrpc-server.php) to initialize the $terms array for a particular taxonomy, thus when the following foreach is called (and skips because of the empty array) then an empty array will be passed along and cause the terms deletion to happen.
Attachments (2)
Change History (8)
#2
in reply to:
↑ 1
@
11 years ago
Replying to markoheijnen:
Related #25037
markoheijnen, it's "related" but it's not the same issue. jstraitiff reported the issue with regards to terms and your related link is to do with categories.
I know that the official terminology refers to them both as being "taxonomies", but a bug definitely exists! Sure, the related link points to the fact that there should always be at least 1 selected category, but I'm not aware of a similar rule existing for terms.
I tried jstraitiff's fix on our test server, but it doesn't resolve the problem completely. Here's an example:
1) The current state of our post is assigned to the "Uncategorized" category, and the term "News"
2) I want to remove the Term "News", so I remove it and send the XML. Our app sends terms as "terms_names" and the categories as "terms" (see XML snippet below). However, "News" still stays attached to the post.
<member><name>terms_names</name><value><struct> <member><name>post_tag</name><value> <array><data></data></array> </value></member> </struct></value></member> <member><name>terms</name><value><struct> <member><name>category</name><value> <array><data> <value><int>1</int></value> </data></array> </value></member> </struct></value></member>
Related #25037