Opened 14 years ago
Closed 14 years ago
#11430 closed defect (bug) (worksforme)
metaWeblog.newPost no categories saved if one is not recognised
Reported by: | Fubra | Owned by: | josephscott |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.9 |
Component: | XML-RPC | Keywords: | needs-patch |
Focuses: | Cc: |
Description
There appears to be a bug in the metaWeblog.newPost functionality of the XML-RPC which causes categories not to be assigned correctly to the new post if one or more of the supplied categories does not exist on the target blog.
For example; the blog has the category 'Cat 1', and the post is submitted with two categories 'Cat 1' and 'Cat 2'. This causes the post to be assigned to no categories at all.
This is not the expected behaviour according to the metaWeblog API RFC (http://www.xmlrpc.com/metaWeblogApi): "On the server side, it's not an error if the category doesn't exist, only record categories for ones that do exist."
A fix would be to check the return value of get_cat_ID() (around line 2216 of xmlrpc.php) and only include it in the $post_categories array if the return value is > 0.
This bug was found in 2.8.6 and exists in the currently available version of 2.9.
Attachments (1)
Change History (9)
#4
@
14 years ago
Would be nice if the original reporter could test if the provided patch does solve the issue.
#5
@
14 years ago
The patch does work, but it's been brought to my attention that the bug exists in two places in the file -- the same bug affects editing posts as well as adding them. As far as I can tell this happens on line 2469, and would need the same fix.
#6
@
14 years ago
- Keywords needs-patch added; has-patch needs-testing removed
k, so needs extra massaging then.
#7
@
14 years ago
Can someone provide a client or code through which I can verify/test this?
I personally cannot see how the proposed patch will fix anything, Nor can i reproduce it using a client (Selecting multiple categories, deleting a few of them via MAnage Categories, Then submitting the post).
On a code level, get_cat_ID() will return 0 for a non-existant category, wp_insert_post() completely ignores the content of the array, and wp_set_object_terms() will skip "empty" terms, 0 being an empty term.
So before i close as worksforme, can someone provide a way to verify this?
#8
@
14 years ago
- Milestone 3.0 deleted
- Resolution set to worksforme
- Status changed from new to closed
Tested manually using http://ditchnet.org/xmlrpc/
Works fine for me.
Creating a draft post with arguments like:
0, "user","password", {title: 'title', description: 'description', categories:['Nice Category', 'Non-Existant Category']}
One category does exist and one doesn't
Closing as Works for Me.
Just added a patch.