Make WordPress Core

Opened 16 months ago

Closed 14 months ago

Last modified 14 months ago

#59125 closed defect (bug) (fixed)

Quick editing date of draft post does not work

Reported by: tristanleboss's profile tristanleboss Owned by: joedolson's profile joedolson
Milestone: 6.4 Priority: normal
Severity: normal Version: 6.3
Component: Quick/Bulk Edit Keywords: has-patch has-unit-tests has-testing-info commit
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 16 months ago.
59125.2.diff (1.8 KB) - added by ivanzhuck 16 months ago.
Updated unit tests with the new logic
59125.3.diff (2.2 KB) - added by khokansardar 16 months 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 (26)

#1 @tristanleboss
16 months 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
16 months 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
16 months 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
16 months 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 16 months ago by tristanleboss (previous) (diff)

#5 @SergeyBiryukov
16 months ago

  • Milestone changed from Awaiting Review to 6.3.1

#6 @tibbsa
16 months 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
16 months 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.


16 months 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
16 months ago

@ivanzhuck
16 months ago

Updated unit tests with the new logic

#10 @audrasjb
16 months 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
16 months ago

#59183 was marked as a duplicate.

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


16 months 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
16 months ago

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

#13 @khokansardar
16 months ago

  • Keywords needs-testing dev-feedback added

#14 @joedolson
16 months ago

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

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


14 months ago

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


14 months 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
14 months 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.

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


14 months ago

#19 @audrasjb
14 months ago

  • Milestone changed from 6.3.2 to 6.4

Given this still needs testing and because we're close to 6.3.2 release candidate, let's move this ticket to milestone 6.4.

#20 @shailu25
14 months ago

Test Report

Patch Tested: https://github.com/WordPress/wordpress-develop/pull/5062

Environment:

WordPress - 6.4 beta2
OS - Windows
Browser - Chrome
PHP - 8.1.2
Active Plugin - None

Actual Results:

  • ✅ After Applying Patch Draft post's date change is now working in Quick Edit
Last edited 14 months ago by shailu25 (previous) (diff)

#21 @joedolson
14 months ago

  • Keywords commit added; needs-testing removed

Although the test above was done against PR 5062, this is a valid test, since the only difference between 5062 and 5358 is that the latter is based on a refreshed version of trunk, so it's less out of date. The changes in the two PRs are identical.

#22 @joedolson
14 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 56802:

Quick/Bulk Edit: Fix inability to quick edit draft post date.

Follow up to [56022] to fix inability to set a date/time in quick editing. Allow a user to set a quick/edit date while preventing accidental date assignments per the original intent.

Props tristanleboss, ivanzhuck, tibbsa, sabernhardt, sergeybiryukov, oandregal, khokansardar, joedolson, shailu25.
Fixes #59125. See #19907.

Note: See TracTickets for help on using tickets.