Wp-calypso: Editor: Cannot save draft after clicking "Cancel scheduling"

Created on 11 May 2018  路  4Comments  路  Source: Automattic/wp-calypso

Steps to reproduce

  1. Create a new post
  2. In the Post Settings > Status, pick a date in the future
  3. Click the "Cancel scheduling" button
  4. Click "Save" link in header

What I expected

The post draft to be saved.

What happened instead

Receive notice: "Saving of draft failed".

Unable to save draft.

Upon publishing post, receive notice: "Post scheduled for Invalid date!" and post is scheduled for date originally scheduled.

Editor Posts [Type] Bug

All 4 comments

Tested and confirmed that after canceling scheduling for a draft post I see a "Saving of draft failed" notice at top right, no errors in the console, and this API call and response:

12125?http_envelope=1&context=edit
public-api.wordpress.com/rest/v1.2/sites/5276229/posts
{"code":400,"headers":[{"name":"Content-Type","value":"application\/json"}],"body":{"error":"invalid_input","message":"Invalid request input"}}

screen shot 2018-05-16 at wed may 16 5 50 17 pm
Seen at https://wordpress.com/post/design5279.wordpress.com/12125 (WP.com Simple / Business Plan) using Chrome 66.0.3359.139 on macOS 10.13.4.

@Automattic/tanooki will look into this

@jsnajdr You might be interested in looking into this issue while in the neighborhood. Here's some notes that @Automattic/tanooki had from our recent team call where we discussed this issue a bit...

Request gets sent with:

{
    date: null
}

and response:

{
    "code":400,
    "headers": [
        {
            "name": "Content-Type",
            "value": "application\/json"
        }
    ],
    "body": {
         "error": "invalid_input",
         "message": "Invalid request input" 
    }
}

This is because the date: null results in an empty input array that is rejected by the API endpoint.

One potential solution is to modify the endpoint to accept either a value or null for date:

'date'  => '(ISO 8601 datetime|null) The post's creation time.',

That would probably allow the null to be passed through so that the endpoint could handle it.

The WP.com endpoint (wpcom-json-api-update-post-v1-2-endpoint) does some magic with dates, e.g., resetting it to "now" when transitioning from "draft" to "publish" or from "scheduled from future" to "publish now".

Also, the core wp_update_post function can clear the date in some circumstances: look for the edit_date param and the $clear_date variable.

However, I don't see the capability to reset the date of a post that already has an explicit date set in the code. The wp-admin editor UI also doesn't have the "Publish Immediately" option.

Was this page helpful?
0 / 5 - 0 ratings