WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#23792 closed defect (bug) (fixed)

Disallow moving of locked posts to the trash

Reported by: azaozz Owned by:
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.6
Component: Administration Keywords: has-patch needs-codex
Focuses: Cc:

Description

Currently we don't check post locks when bulk moving posts to the trash on the All Posts screen and in wp_ajax_trash_post(). A post locked check was added when moving to the trash from the New/Edit Post screen in http://core.trac.wordpress.org/changeset/23661#file5.

The new UI on the All Posts screen prevents selecting a locked post for bulk actions, but we still should make sure a post is not locked right before moving it to the trash.

Attachments (2)

23792-bulk-edit.diff (919 bytes) - added by pdclark 7 years ago.
Check for locked posts in batch edit, edit.php
locked-not-updated.png (56.0 KB) - added by pdclark 7 years ago.
Notice when trash request made for locked post

Download all attachments as: .zip

Change History (11)

#1 @azaozz
7 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 3.6
  • Version set to trunk

#2 follow-ups: @pdclark
7 years ago

  • Keywords dev-feedback added

I've attached and tested a patch for bulk-edit.php.

I left code out for wp_ajax_trash_posts() because I don't see it called or hooked anywhere, so I'm unsure how to test that output is correct. Do you know where it is used, @azaozz ?

#3 in reply to: ↑ 2 @SergeyBiryukov
7 years ago

Replying to pdclark:

I left code out for wp_ajax_trash_posts() because I don't see it called or hooked anywhere

wp_ajax_trash_post() is called via Plupload and SWFUpload handlers:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/js/plupload/handlers.js#L139
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/js/swfupload/handlers.js#L95

#4 in reply to: ↑ 2 ; follow-up: @azaozz
7 years ago

Replying to pdclark:

Sergey beat me to it :) Btw this code is unreachable now, there only for back-compat.

I've attached and tested a patch for bulk-edit.php.

We should be checking the post lock before moving to the trash, i.e. that code block needs to be above if ( !wp_trash_post($post_id) ). Also not sure if we should exit when a post is locked, perhaps just skip it and continue moving the rest to the trash.

@pdclark
7 years ago

Check for locked posts in batch edit, edit.php

@pdclark
7 years ago

Notice when trash request made for locked post

#5 in reply to: ↑ 4 @pdclark
7 years ago

Replying to azaozz:

We should be checking the post lock before moving to the trash, i.e. that code block needs to be above if ( !wp_trash_post($post_id) ). Also not sure if we should exit when a post is locked, perhaps just skip it and continue moving the rest to the trash.

Patch updated to display lock notice, and check *before* trashing posts. ;)

Requests to trash a locked posts display this notice, which already existed on edit.php line 241.

Since wp_ajax_posts() is only called for Media (plupload, swfupload, which have no post locks or trash, and it's backwards compatibility code that's not accessed from anywhere, I assume it shouldn't be modified for this ticket? Is that correct?

#6 @azaozz
7 years ago

In 23747:

Bulk actions: do not move locked posts to the trash, props pdclark, see #23792

#7 @pdclark
7 years ago

Sweet! Thanks for the cleanup in the commit -- much nicer as a single-line defaults declaration, and good catch on adding locked to remove_query_arg()

#8 @DrewAPicture
6 years ago

  • Keywords has-patch needs-codex added; needs-patch dev-feedback removed
  • Resolution set to fixed
  • Status changed from new to closed

Seems like everything was covered in [23747]. Feel free to re-open if it's incomplete.

#9 @dinsan
5 years ago

I have updated Codex. http://codex.wordpress.org/Posts_Screen#Actions

This is my first attempt at editing Codex. Please let me know if this was ok.

Note: See TracTickets for help on using tickets.