Make WordPress Core

Opened 9 years ago

Closed 13 months ago

Last modified 13 months ago

#31635 closed defect (bug) (fixed)

Bulk Edit -> Publish should publish scheduled posts

Reported by: siobhan's profile siobhan Owned by: oglekler's profile oglekler
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: Quick/Bulk Edit Keywords: has-patch has-unit-tests commit has-screenshots
Focuses: ui Cc:


Here's the flow that I was working through:

  1. Scheduled about 15 posts to be published on the site at a later date.
  2. Decided I wanted to just publish them now.
  3. Used Bulk Edit to change the status of all of the posts to published. Saved
  4. Went about my business thinking they were published
  5. Later visited the site and they weren't published.

6 Went back into the posts and they're still marked as scheduled.

  1. Had to manually go in and change the date on each post to get them published.

This was really, really annoying. Especially since, as I was able to take the action of Bulk Edit -> change status to published, I thought that what I had done had worked. There was no indication that it hadn't.

This could be solved in a number of ways:

  1. If a user bulk edits and selects publish, the date on the post is changed to the current date and time and the posts are published as expected.
  1. If posts are scheduled and the user selects them to bulk edit, there is no option to change the status to published.
  1. If the user takes the action of trying to change the status of scheduled posts to published, the message is changed from "# Posts Updated" to "Scheduled posts have not been published."

Attachments (4)

31635.patch (3.4 KB) - added by cadic 17 months ago.
31635-2.patch (3.2 KB) - added by cadic 16 months ago.
Patch including both future and draft post statuses
28c6146f6d15486ed7a3e573f7ab8508.gif (665.6 KB) - added by audrasjb 13 months ago.
Before patch: nothing happens :'(
c7e9ed4a4bbee1cafd512f6df3e0f666.gif (807.6 KB) - added by audrasjb 13 months ago.
After patch: bulk edit works fine \o/

Download all attachments as: .zip

Change History (30)

#1 @siobhan
9 years ago

  • Keywords make-flow added

#2 @Clorith
4 years ago

  • Type changed from enhancement to defect (bug)

Changing the ticket type of this to a bug, as the behavior is as expected (published a scheduled post) in the quick edit as well, which is essentially bulk-edit for a singular post

#3 @webcommsat
18 months ago

  • Keywords needs-patch added; make-flow removed

Component ticket review today

  • @webcommsat @oglekler @nalininontopsnewsuk

All reported this problem occurs: 5.9, 6.0, 6.1.1.

@siobhan has highlighted three ways of addressing this bug. Option 1 would be the most preferable.

We suggested that if the solution for option 1 was not possible quickly, in the interim whether a patch just adding the wording in Option 3 so users knew that the posts were not published using 'Bulk Edit'.

Ticket updated as needing a patch.

Update: this ticket will be one of the ones @oglekler will be working on and inviting others who wish to work to do so with her at WordCamp Asia on February 17, 2023. People can also assist on Slack.

Last edited 18 months ago by webcommsat (previous) (diff)

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

18 months ago

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

17 months ago

  • Keywords has-patch has-unit-tests added; needs-patch removed

Updated bulk_edit_posts(): scheduled posts will be published immediately if post status is set to "publish" on the bulk edit.

Added unit tests to cover this behaviour

Trac ticket:

#6 @cadic
17 months ago

I've added a patch and Unit tests.

17 months ago

#7 @oglekler
17 months ago

  • Keywords needs-testing added

#8 @oglekler
16 months ago

Thank you @cadic,

I've tested the patch with WordPress 6.3-alpha-55505-src.

This Patch (and related unit test) look fine and work as expected.

I am wondering if we need to change the post date for posts we are publishing from drafts if it is in the past or not, but I assume this is out of the scope for this ticket.

#9 @cadic
16 months ago

@oglekler yes, it looks out of scope to assign current time as post_date of posts being published from drafts during bulk edit.

It may be an easy adjustment within the current change (and will also worth adding another unit test case)

diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php
index 0c9f9250ed..bdb07604a4 100644
--- a/src/wp-admin/includes/post.php
+++ b/src/wp-admin/includes/post.php
@@ -665,7 +665,7 @@ function bulk_edit_posts( $post_data = null ) {
                unset( $post_data['tax_input']['post_format'] );
                // Reset post date of scheduled post to be published.
-               if ( 'future' === $post->post_status && 'publish' === $post_data['post_status'] ) {
+               if ( in_array( $post->post_status, array( 'future', 'draft' ), true ) && 'publish' === $post_data['post_status'] ) {
                        $post_data['post_date']     = current_time( 'mysql' );
                        $post_data['post_date_gmt'] = '';

#10 @oglekler
16 months ago

Thank you, @cadic, I believe that it makes sense. When user is publishing something, he/she expects this to be fresh on the block news and not be published on time what it was drafted. I imagine that user can prepare something and sitting on it waiting for right timing and then publish. If the time gap is not big he/she cannot even notice that it was published at past but in some cases date is matter for users and SEO as well and inaccurate dates can be potentially looks like tricks from the site owner or caching bug.

#11 @webcommsat
16 months ago

Thank you @cadiac for the patch. I have tested it like @oglekler (thank you too for testing and comments), and found no issues.

The second issue about the publication date would be useful to have addresses, and I agree this would need to be in an additional ticket. I would second Olga's comments on tihs.

16 months ago

Patch including both future and draft post statuses

#12 @cadic
16 months ago

@webcommsat thanks for the feedback. I've already updated the patch and unit tests: it will apply the date reset to drafts as well when bulk publishing.

Please feel free to link the existing PR to a new issue whoever creates it.

#13 @oglekler
16 months ago

@cadic @webcommsat,
I've created a new ticket #57947 to address the Draft state issue, but I agree that it is easier to tackle this with one patch not to have margin issues or duplicate a code.

Thank you 🙏

#14 @webcommsat
16 months ago

We need to get some more tests on this and the updated patch. Thanks @cadic for all the additional changes.

I will put it on the dev chat agenda this coming week. Let's hope this can be moved forward for 6.3.

Once we have the updated patch tests done, we can mark the other ticket opened as a duplicate, if it is no longer needed. Thanks @cadic and @oglekler , it is so good to see this ticket moving forward.

@marybaum can you please also add this to your list for testing. Thanks.

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

14 months ago

#16 @audrasjb
14 months ago

  • Milestone set to 6.3

Moving this for 6.3 consideration.

#17 @pavanpatil1
14 months ago


Tested the patch - It is working fine while change the status of selected multiple posts. However, If try to quick edit a single post it is not working. Added the screencast below-

#18 @oglekler
13 months ago

Hi, I tested the patch (WP 6.3-alpha-55505-src) and from my point of view behaviour with posts which are scheduled for the future is expected, video:

There was another patch which was fixing this Published/Scheduled option text, and it looks like it is in the trunk now.

#19 @oglekler
13 months ago

  • Owner set to oglekler
  • Status changed from new to assigned

#20 @oglekler
13 months ago

  • Keywords commit added

I've tested the patch again, and it is working as expected in the scope of the ticket and has unit tests, I am marking this for review to commit.

13 months ago

Before patch: nothing happens :'(

13 months ago

After patch: bulk edit works fine \o/

#21 @audrasjb
13 months ago

  • Keywords has-screenshots added; needs-testing removed

Self assigning for commit.

#23 @audrasjb
13 months ago

PR4774 refreshes the latest patch.

#24 @audrasjb
13 months ago

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

In 56123:

Quick/Bulk Edit: Ensure scheduled posts are published when using Bulk Edit.

This changeset ensures scheduled posts are actually published when changing their status to "Published" using bulk edit. Also adds related unit tests.

Props siobhan, Clorith, webcommsat, cadic, oglekler, audrasjb, pavanpatil1.
Fixes #31635.

Note: See TracTickets for help on using tickets.