Make WordPress Core

Opened 7 weeks ago

Last modified 45 hours ago

#59125 accepted defect (bug)

Quick editing date of draft post does not work

Reported by: tristanleboss's profile tristanleboss Owned by: joedolson's profile joedolson
Milestone: 6.3.2 Priority: normal
Severity: normal Version: 6.3
Component: Quick/Bulk Edit Keywords: has-patch needs-testing has-unit-tests has-testing-info
Focuses: javascript Cc:

Description

Hello,
Using a fresh WP 6.3 setup with no plugins nor themes:

  • create a draft post
  • go back to the list of post
  • quick edit this post and change the date post year (for example)
  • press the "Save" button
  • the save succeed but the date is not saved: the date is still the old one

It's an unexpected behavior. 1) You can clearly edit the date in the UI. 2) It's perfectly sane to want to set a draft date so you know when you will have the post published in the future.

I maybe wrong but I have the feeling it's missing "hidden_(aa|jj|mm|hh|mn|ss)" hidden input fields. Indeed, in the _wp_translate_postdata function, to be able to trigger the edit date code, it needs those fields. There is a foreach checking for their existence.

Attachments (3)

59125.diff (718 bytes) - added by ivanzhuck 6 weeks ago.
59125.2.diff (1.8 KB) - added by ivanzhuck 6 weeks ago.
Updated unit tests with the new logic
59125.3.diff (2.2 KB) - added by khokansardar 5 weeks ago.
With this patch posts shouldn't be assigned a date unless date explicitly done by the user when needed.

Download all attachments as: .zip

Change History (20)

#1 @tristanleboss
7 weeks ago

If you still use "Classic Editor" plugin, you can still edit the date. I didn't find a way to set the date using Gutenberg.

#2 @tristanleboss
7 weeks ago

  • Summary changed from Quick editing date of draf post does not work to Quick editing date of draft post does not work

#3 follow-up: @sabernhardt
7 weeks ago

  • Component changed from General to Quick/Bulk Edit
  • Focuses javascript added
  • Keywords needs-patch added

If I understand #19907 correctly, the Quick Edit feature needed to prevent setting the date unintentionally. However, r56022 does not allow setting a date/time you want in Quick Edit.

#4 @tristanleboss
7 weeks ago

Today, changing the date field of the Quick Edit panel of a draft post does absolutely nothing.
No date is changed in the database: post_date and post_modified are just changed with the current date.
Changing the date from the post edit page still works if you use the Classic Editor plugin.

What I don't understand is why such a change was done in the first place. It has been like that for 12 years and, all of a sudden, the behavior changes without any UX change. The #19907 ticket just collected 26 comments in 12 years so clearly not a problem for many users.

When you create content, you sometime know when you want to publish it (a news, a paid content, ...) so it was very convenient to be able to preset the publish date.

I think the best solution was just to leave the date fields empty when post_status === draft and post_date === post_modified. This way, you can set a date in Quick Edit panel or decide to keep it in sync with post_modified which means it will be published with the current date when the user will click the publish button.

Or, do a bit like the Classic Editor which shows "Publish : immediatly [Edit]" with the edit button to set a custom date. It can be exactly the same way in the Quick Edit panel of a draft post... maybe instead of "immediatly" use a sentence that says the date will be the one when the post is published. I don't know how to phrase it in English: "use date at the time of publication"?

Last edited 7 weeks ago by tristanleboss (previous) (diff)

#5 @SergeyBiryukov
7 weeks ago

  • Milestone changed from Awaiting Review to 6.3.1

#6 @tibbsa
6 weeks ago

I can confirm that this has also caused some problems for some of our users. For example, we have one site where the post times were manually set to enforce ordering of a multi-page publication. We have "got around it" by _scheduling_ publication at various times, which should result in the public seeing everything correctly, but it made reviewing the drafts difficult because we could not get them in the correct order prior to publication. The problem "fixed" in #19907 has had what I think are unintended consequences.

#7 in reply to: ↑ 3 @SergeyBiryukov
6 weeks ago

Replying to sabernhardt:

If I understand #19907 correctly, the Quick Edit feature needed to prevent setting the date unintentionally. However, r56022 does not allow setting a date/time you want in Quick Edit.

Indeed, this appears to be a regression, as the change does not account for setting the date explicitly when needed.

This ticket was mentioned in PR #5025 on WordPress/wordpress-develop by @ivanzhuck.


6 weeks ago
#8

  • Keywords has-patch added; needs-patch removed

Hello,

I've added a condition to _wp_translate_postdata() which allow to save the date for draft posts with the quick edit form.
Please review.

@ivanzhuck
6 weeks ago

@ivanzhuck
6 weeks ago

Updated unit tests with the new logic

#10 @audrasjb
6 weeks ago

  • Milestone changed from 6.3.1 to 6.3.2

WP 6.3.1 is going to be released in the next few days, so let's move this ticket to 6.3.2 to give it more time to be committed and backported.

#11 @SergeyBiryukov
6 weeks ago

#59183 was marked as a duplicate.

This ticket was mentioned in PR #5062 on WordPress/wordpress-develop by @khokansardar.


5 weeks ago
#12

This PR fix draft post date change save issues in quick edit, considering ticket #59125 issue and previously ticket task #19907 done patch which create issues ( not updating date/time ) for post status - ( 'draft', 'pending', 'auto-draft' ).

Trac ticket: https://core.trac.wordpress.org/ticket/59125

@khokansardar
5 weeks ago

With this patch posts shouldn't be assigned a date unless date explicitly done by the user when needed.

#13 @khokansardar
5 weeks ago

  • Keywords needs-testing dev-feedback added

#14 @joedolson
5 weeks ago

  • Owner set to joedolson
  • Status changed from new to accepted

This ticket was mentioned in Slack in #core by joemcgill. View the logs.


4 days ago

This ticket was mentioned in PR #5358 on WordPress/wordpress-develop by @joedolson.


45 hours ago
#16

  • Keywords has-unit-tests added

This is a fresh PR based on 5062 but built on current trunk

Trac ticket: https://core.trac.wordpress.org/ticket/59125

#17 @joedolson
45 hours ago

  • Keywords has-testing-info added; dev-feedback removed

PR 5025 just reverses in PHP the change made in JS, so it still causes the original problem from #19907. So I don't think that's a viable fix.

PR 5062, however, does fix both the original problem and the new issue. However, it needs tests updates. Whether or not quick edit saves a post date is now conditional on whether a date was passed that's different from the previous date, and the test passes a new value. I've added new tests and rebased the PR on trunk.

Testing:

1) Confirm that the test in #19907 result in an unchanged post date.
2) Confirm that the test steps in this report result in a changed post date.

Note: See TracTickets for help on using tickets.