Opened 12 years ago
Closed 12 years ago
#22335 closed enhancement (fixed)
XML-RPC: wp.editPost changes post_status from 'inherit' to 'draft'
Reported by: | DaEnno | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | 3.4 |
Component: | XML-RPC | Keywords: | commit |
Focuses: | Cc: |
Description
To send a blogpost via XML-RPC interface I take the following steps:
- Upload all images via wp.uploadFile.
- Receive the IDs and URLs of the uploaded images and insert image markup into the blogpost.
- Create the actual blogpost via wp.newPost.
The Problem: the uploaded images will show up in the blogpost but can't be found in the media library.
This seems to appear due to a bug in the function "attach_uploads" in the file class-wp-xmlrpc-server.php. The function sets the post_parent of all images to the ID of the actual blogpost. But it does not update the image's "post_status" from "draft" to "inherit".
The images are included when displaying the image count in the media library but they are not listed there.
Attachments (1)
Change History (13)
#2
@
12 years ago
You can't upload an image with the post status 'inherit'. Of course, the parent will be created after the image is uploaded.
That's why the initial "post_status" of an image is "draft".
This is the point where the "attach_uploads" function should be doing it's job properly by setting the image's "post_status" to "inherit".
When I first recognized this I thought I could get around it by setting the image's post status afterwards via "wp.editPost". Unfortunately this doesn't work either. This is due to some switch-statement where 'inherit' is not included for the "post_status", so it defaults to draft.
You can see this in the function "mw_editPost", starting with
switch( $content_struct["{$post_type}_status"] ) {
#3
@
12 years ago
The default "post_status" isn't draft but inherit. It seems you edit the image through wp.editPost and that this can be the reason of post status change.
Also attach_uploads shouldn't really care about post_status and what it is.
#4
@
12 years ago
The default "post_status" isn't draft but inherit.
Ok, sorry for mistaking. But does that make sense? It inherits from... what?
It seems you edit the image through wp.editPost and that this can be the reason of post status change.
Yes, I do. I have to set post_excerpt and post_content manually since I can't send all the data needed when executing wp.uploadFile. Nevertheless don't you think it's weird this makes the image draft instead of inherit?
Also attach_uploads shouldn't really care about post_status and what it is.
I thought attach_uploads is responsible for making images children of a post. That's why an post_status of inherit makes sense to me.
#5
@
12 years ago
The status of an image is always inherit. It makes more sense then others.
So the real issue is the change of post status and I can see why that can happen. I will look in what the best solution can be for that.
The best is to create a way to change the media through the API but that isn't something that can be done for 3.5.
#6
@
12 years ago
Ok.
I thought the only thing to do is to add...
case 'inherit':
... to...
switch( $content_struct["{$post_type}_status"] ) { case 'draft': case 'pending': case 'private': case 'publish': $post_status = $content_struct["{$post_type}_status"]; break;
#7
@
12 years ago
- Milestone changed from Awaiting Review to 3.5
- Type changed from defect (bug) to enhancement
- Version set to 3.4
I do something like that for the wp method. Older methods will stay untouched unless there is a bug and this is an enhancement to make more possible through the existing methods
That doesn't make sense to me. Tried to look into the code but it should always be inherit. There is no post_status change anywhere