Opened 12 years ago
Closed 10 years ago
#26832 closed defect (bug) (fixed)
Unable to force delete using get_delete_post_link()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.4 | Priority: | normal |
| Severity: | normal | Version: | 3.8 |
| Component: | Posts, Post Types | Keywords: | needs-testing has-patch |
| Focuses: | Cc: |
Description
I seem to be unable to force delete when using get_delete_post_link()
Doing the following inside the loop sends the post to trash.
get_delete_post_link( $post_id, '', true );
Shouldn't passing true as the third parameter cause the post to be permanently deleted?
http://codex.wordpress.org/Function_Reference/get_delete_post_link
Attachments (2)
Change History (16)
#2
@
12 years ago
bcworkz
Perhaps this just needs an update to the Codex explaining that define( 'EMPTY_TRASH_DAYS', 0 ); must be defined in config.php in order for force delete to work? Then again, not everybody would want to disable trash completely across their whole site just to make the get_delete_post_link function work.
#5
@
10 years ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 4.4
- Owner set to chriscct7
- Status changed from new to assigned
Feedback is requested on whether the function should change as proposed. It seems to me to make more sense.
This ticket was mentioned in Slack in #core by chriscct7. View the logs.
10 years ago
#8
@
10 years ago
- Keywords needs-patch added; has-patch commit removed
The issue isn't in the get_delete_post_link() function, so 26832.patch will have no effect. The issue is that a post that's "deleted" with the link from get_delete_post_link( $post_id, '', true ) is actually trashed.
The issue is in the logic in the 'delete' case in wp-admin/post.php which only deletes a post if EMPTY_TRASH_DAYS is empty.
#9
follow-up:
↓ 13
@
10 years ago
- Keywords has-patch needs-testing added; needs-patch removed
26832.2.patch should address this, but needs full testing and we also need to check if anywhere in the admin is using a delete link when it should be using a trash link.
#10
@
10 years ago
- Keywords needs-patch added; has-patch needs-testing removed
@johnbillion what about adding a forcedelete action?
Also, you need the changes in the original patch because without them, the link runs the trash not delete action.
#12
@
10 years ago
I'll contradict myself and point out I was misreading the original conditional. Ignore comment:10
#13
in reply to:
↑ 9
@
10 years ago
- Keywords has-patch added; needs-patch removed
Replying to johnbillion:
26832.2.patch should address this, but needs full testing and we also need to check if anywhere in the admin is using a
deletelink when it should be using atrashlink.
We use a delete link in WP_Posts_List_Table::handle_row_actions() and attachment_submit_meta_box(). Both look proper and are only displayed if EMPTY_TRASH_DAYS is disabled or the post is already in Trash.
The problem appears to be in source:/trunk/src/wp-admin/post.php#L291
$force = ! EMPTY_TRASH_DAYS;The constant defaults to 30, so for most people
$forcewill befalse. This appears to be logic to send deletions to trash unless trash is disabled by setting the constant to 0. As this is in the 'delete' case and not the 'trash' case, this logic seems out of place to me. If code reaches this point, the trash option should not even be a possibility, though there appears to be some reason for not deleting attachments which I'm unfamiliar with, and the reason I've not provided a patch.