Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posts: scheduled posts aren't published after clicking "Publish" in the posts list #4330

Closed
designsimply opened this issue Mar 25, 2016 · 10 comments
Assignees
Labels

Comments

@designsimply
Copy link
Contributor

Steps to reproduce:

  1. Create and schedule a new post
  2. Go to https://wordpress.com/ > My Sites > Blog Posts > Scheduled
  3. Click "Publish" below the post

Result: clicking "Publish" in the list of scheduled posts triggers two messages, "Updating Post …" and "Updated," however, the post does not get published and remains in the scheduled posts list (2m52s)

screen shot 2016-03-25 at fri mar 25 3 44 04 pm
Seen at https://wordpress.com/posts/scheduled/watchingstormsrollby.me using Firefox 45.0.1 on Mac OS X 10.11.13, also tested with Chrome 49.0.2623.87 on Mac OS X 10.11.13

Possibly related: #3886, #3969

/hat tip @helenhousandi for the report

@designsimply designsimply changed the title Posts: schedules posts aren't published after clicking "Publish" in the posts list Posts: scheduled posts aren't published after clicking "Publish" in the posts list Mar 26, 2016
@lancewillett
Copy link
Contributor

I can repeat this one — "Publish" action does not actually publish the post; I'd expect this action to change the post publish date to now (current day, time) and publish it, regardless of the future scheduled setting.

@alisterscott
Copy link
Contributor

Confirmed this is still an issue:

publish-scheduled

@hoverduck
Copy link
Contributor

This is still a problem. I did some investigation, and found the problem is that the API request (here) to publish it only sets { status: "publish" }. If you make it instead { status: "publish", date: new Date() } then it acts as expected, publishing the post with a timestamp of Now rather than whenever it was originally scheduled.

Of course I'm sure that by itself would have unintended consequences, and needs to be further refined, but I'm not familiar enough with how everything connects to say offhand what the full solution should be.

Hat tip to @catehstn for the ping saying it's still an issue

@designsimply designsimply added the Good First Issue Small, contained issues. label May 23, 2017
@lancewillett
Copy link
Contributor

Another nudge today from @catehstn

Steps:

  1. Schedule a post for PM
  2. Realize you wanted AM
  3. Click "Publish" to publish it now instead
  4. Nothing happens

@mcsf
Copy link
Member

mcsf commented Jul 25, 2017

Related: promoting a draft to published from within Posts

  1. Go to Posts > Drafts
  2. Click Publish on a draft
  3. Wait for completion
  • Expected: either remain in Drafts and have that selected post disappear once it's published, or be taken to Published and see that post in that list
  • Observed: navigation still stays Drafts (Rascunhos in screencast), but post counter is updated to reflect published count instead of drafts count.

calypso-draft-to-published

@mcsf
Copy link
Member

mcsf commented Jul 25, 2017

Concerning scheduled posts, two observations:

  • Seeing the label Publish in Posts > Scheduled can be confusing ("didn't I already say I wanted this published in the future?"). What that button actually aims to do is "Publish Now Instead".
  • From what I see, the editor itself doesn't offer such a "Publish Now Instead" option for scheduled posts. Instead, it allows the user to set the publishing date to something in the present/past and publish. Same goes for WP-Admin.

Coming up with a transversal way of dealing with scheduled posts that is clear and comforting for the user would be nice.

@lancewillett
Copy link
Contributor

Related to this flow, but I know separate for the implementation, are two glaring bugs or UX gaps:

  1. Inconsistent Time Picking Format #13769 — the time zone and format in the scheduled post picker doesn't always match the blog settings (24-hour setting but shows AM/PM text label; time zone of the local user shown in the picker instead of the blog's time zone).
  2. Site Settings: can't set locale options for Jetpack sites #11316 — can't set the time zone for a Jetpack site in Calypso yet.

@iandunn iandunn self-assigned this Jul 25, 2017
@iandunn
Copy link
Contributor

iandunn commented Jul 25, 2017

To expand on Scott's findings, the root cause is that Core's wp_insert_post() expects posts being published to have a post_date_gmt in the past. If it detects a future date, then it'll override the post_status to future.

I can reproduce the issues that @mcsf reported above, but they seem to have different causes.

For context, Core doesn't have a similar flow to Calypso for this, where you can publish from the All Posts list. In wp-admin, you have to navigate to the Edit Post screen, and either:

  • A) change the status from Scheduled to Draft, then update the post, then publish the post; or
  • B) set the date to be in the past, and then publish the post.

If you do A, then Core wipes out the date, and wp_insert_post() later sets it to be the current timestamp, because wp_insert_post() doesn't expect drafts to have a date set. If you do B, then you've explicitly set a valid date, and everything gets processed succesfully.

Back to Calypso... The WPCOM API endpoint already explicitly sets valid dates for drafts before wp_insert_post() is called, so it seems like we'd just need to expand that to cover scheduled posts as well.

@hoverduck, you mentioned some unintended consequences, though. I'm not seeing anything in my testing so far, can you point me in the right direction?

@iandunn
Copy link
Contributor

iandunn commented Jul 26, 2017

If anyone's curious, I've prepared D6575-code with the proposed changes.

@iandunn
Copy link
Contributor

iandunn commented Aug 17, 2017

This is fixed as of r160864-wpcom.

Since it was API-side, it'll need to be merged into Jetpack to work on Jetpack sites. The patch was tested with one, though, so it should work without any modifications to the endpoint. CC @dereksmart

@iandunn iandunn closed this as completed Aug 17, 2017
michaeldcain pushed a commit to Automattic/jetpack that referenced this issue Apr 27, 2018
When publishing scheduled posts directly from the `posts/scheduled/{site}` screen in Calypso, the API request to the update endpoint would only the `post_status` field. When the endpoint passed that data on to `wp_insert_post()`, it would be considered invalid input, because it the existing scheduled `post_date_gmt` field was used, and that date is in the future.

Core doesn't have a flow similar to Calypso's, so it never encounters this condition normally, and it expects posts to have dates in the past when they're being published. In response to the invalid input, `wp_insert_post()` would override the `post_status` and set it back to `future`, so the post would never be published.

The solution to that is to explicitly set the date to the current timestamp before calling `wp_insert_post()`.

Fixes Automattic/wp-calypso#4330
Differential Revision: https://[private link]

Merges r160864-wpcom.
michaeldcain pushed a commit to Automattic/jetpack that referenced this issue Apr 27, 2018
When publishing scheduled posts directly from the `posts/scheduled/{site}` screen in Calypso, the API request to the update endpoint would only the `post_status` field. When the endpoint passed that data on to `wp_insert_post()`, it would be considered invalid input, because it the existing scheduled `post_date_gmt` field was used, and that date is in the future.

Core doesn't have a flow similar to Calypso's, so it never encounters this condition normally, and it expects posts to have dates in the past when they're being published. In response to the invalid input, `wp_insert_post()` would override the `post_status` and set it back to `future`, so the post would never be published.

The solution to that is to explicitly set the date to the current timestamp before calling `wp_insert_post()`.

Fixes Automattic/wp-calypso#4330
Differential Revision: https://[private link]

Merges r160864-wpcom.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants