WordPress.org

Make WordPress Core

Opened 13 months ago

Closed 13 months ago

Last modified 2 weeks 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 13 months ago.
Check for locked posts in batch edit, edit.php
locked-not-updated.png (56.0 KB) - added by pdclark 13 months ago.
Notice when trash request made for locked post

Download all attachments as: .zip

Change History (11)

comment:1 azaozz13 months ago

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

comment:2 follow-ups: pdclark13 months 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 ?

comment:3 in reply to: ↑ 2 SergeyBiryukov13 months 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

comment:4 in reply to: ↑ 2 ; follow-up: azaozz13 months 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.

pdclark13 months ago

Check for locked posts in batch edit, edit.php

pdclark13 months ago

Notice when trash request made for locked post

comment:5 in reply to: ↑ 4 pdclark13 months 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?

comment:6 azaozz13 months ago

In 23747:

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

comment:7 pdclark13 months 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()

comment:8 DrewAPicture13 months 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.

comment:9 dinsan2 weeks 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.