#22220 closed defect (bug) (fixed)
XML-RPC wp.editPost clears post categories
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | XML-RPC | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
According to http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.editPost
"Only needs to contain fields that you wish to modify; all other fields will retain their current values."
When I only post custom_fields to update the custom fields of a post (custom post type by the way, didn't check for normal posts) the categories of the post are removed (now "Unassigned").
I think the source of the problem might be the following part in wp_insert_post:
// Make sure we set a valid category. if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) { // 'post' requires at least one category. if ( 'post' == $post_type && 'auto-draft' != $post_status ) $post_category = array( get_option('default_category') ); else $post_category = array(); }
Attachments (1)
Change History (17)
#2
@
13 years ago
Seems somewhat related, but the patch won't fix the issue for non-'post' post types
edit: yes this was regarding the build in "Category" taxonomy. Didn't test for other taxonomies. I think a proper fix wouldn't call wp_set_post_categories in post.php:2652 when nothing should be changed.
#3
@
13 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from assigned to closed
I close this as duplicate. Since it is the same issue as #19954. The patch I wrote doesn't seem to fix it properly then.
I will start writing unit tests for it and hopefully this can be fixed in 3.5
#4
@
13 years ago
My apologies, I retried and the patch from #19954 does seem to resolve the issue. Thanks.
#6
@
13 years ago
- Milestone set to 3.5
- Resolution duplicate deleted
- Status changed from closed to reopened
A switch to wp_update_post would be sufficient to fix XML-RPC.
#7
follow-up:
↓ 9
@
12 years ago
What are we doing here? I don't know how feasible it is to switch the _insert_post() method to wp_update_post(). This needs unit tests, I gather.
#9
in reply to:
↑ 7
@
12 years ago
- Keywords needs-patch punt added
Replying to nacin:
What are we doing here? I don't know how feasible it is to switch the _insert_post() method to wp_update_post(). This needs unit tests, I gather.
We definitely need some tests to cover this agreed.
I also think that we should maybe make _insert_post() work differently for new/editing as we should be using wp_update_post when editing for sure.
#11
in reply to:
↑ 10
@
12 years ago
Replying to nacin:
Thanks, I guess we just need the requisite tests now ;)
#12
follow-up:
↓ 13
@
12 years ago
- Keywords commit added; needs-unit-tests punt removed
- Owner changed from markoheijnen to westi
- Status changed from reopened to assigned
Basic unit test in [UT1133].
#15
@
12 years ago
The check for IXR_Error makes sense, but I can't reproduce "Previously the test created a post that the test user couldn't edit and so the Post Editing failed." [UT1137] The user was an editor and should have been able to modify any post. The test passed for me (with patch applied), which included the updating of the post title. Perhaps something to look into your local copy of the tests.
You are using the build in taxonomy "Category" or are you using a custom taxonomy?
Maybe this is related: #19954?