WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#18812 closed defect (bug) (fixed)

XML-RPC newPost need more dashboard-like behavior for publishing posts

Reported by: koke Owned by: josephscott
Milestone: 3.3 Priority: normal
Severity: normal Version:
Component: XML-RPC Keywords: has-patch mobile
Focuses: Cc:

Description

Right now, metaWeblog.newPost calls wp_insert_post before:

  • Attaching media uploads
  • Set/unset sticky
  • Set custom fields
  • Set post formats

This is probably done since all those actions need the post ID, but it can break some plugins that rely on the publish_post action hook since the post is not complete at that point.

The idea is to make it behave more like wp-admin:

  • Save the post as 'auto-draft'
  • Attach uploads, set custom fields, ...
  • Update with proper status

Attachments (4)

wp-18812.diff (1.1 KB) - added by koke 3 years ago.
Patch to set 'auto-draft' on metaWeblog.newPost until the post is complete
18812.diff (1.6 KB) - added by nacin 3 years ago.
rpc.diff (1.5 KB) - added by josephscott 3 years ago.
18812.2.diff (1.6 KB) - added by josephscott 3 years ago.

Download all attachments as: .zip

Change History (15)

koke3 years ago

Patch to set 'auto-draft' on metaWeblog.newPost until the post is complete

comment:1 daniloercoli3 years ago

  • Cc ercoli@… added

comment:2 nacin3 years ago

It'd be nice to do get_default_post_to_edit() then do a single wp_insert_post at the end.

nacin3 years ago

comment:3 follow-up: nacin3 years ago

Untested patch.

comment:4 follow-up: josephscott3 years ago

Is there a basic test case plugin that we can use to test the problem and potential solutions?

comment:5 in reply to: ↑ 4 koke3 years ago

Replying to josephscott:

Is there a basic test case plugin that we can use to test the problem and potential solutions?

The case I know is wordpress.com publicize, when publishing posts with images, the post in facebook doesn't have any of the images.
I guess any other facebook auto-publish plugin would have the same issue

comment:6 in reply to: ↑ 3 josephscott3 years ago

Replying to nacin:

Untested patch.

I tried this patch and it generated two of these PHP issues:

Warning: addslashes() expects parameter 1 to be string, object given in wp-includes/wp-db.php on line 783

I'm going to try out the orginal wp-18812.diff and see what happens there.

josephscott3 years ago

comment:7 josephscott3 years ago

Updated patch that I've tested using the Publicize feature on WPCOM and it appears to address the problem mentioned in the ticket. I'm soliciting a few more tests before giving this a full green light to commit to -trunk.

That said, this change is relatively small and looks like it shouldn't cause problems for other clients.

josephscott3 years ago

comment:8 josephscott3 years ago

After chatting with nacin about this, he found what was triggering the error with his patch. I've uploaded an updated version of his ( 18812.2.diff ).

Initial testing looks good.

comment:9 josephscott3 years ago

I talked with koke and he was good with this patch. At this point I think it ready to commit.

comment:10 nacin3 years ago

  • Milestone changed from Awaiting Review to 3.3

comment:11 josephscott3 years ago

  • Owner set to josephscott
  • Resolution set to fixed
  • Status changed from new to closed

In [18933]:

Follow the pattern of wp-admin a bit more for metaWeblog.newPost by using get_default_post_to_edit() to generate a post ID before the post is actually published.

Fixes #18812
Props koke, nacin

Note: See TracTickets for help on using tickets.