[wp-trac] [WordPress Trac] #55158: Attachment removed from grid view if the delete request is failed
WordPress Trac
noreply at wordpress.org
Sat Feb 12 19:03:32 UTC 2022
#55158: Attachment removed from grid view if the delete request is failed
----------------------------+-----------------------------
Reporter: kapilpaul | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: trunk
Severity: normal | Keywords:
Focuses: ui, javascript |
----------------------------+-----------------------------
While working with media attachments got a bug. When try to delete a media
attachment from modal by pressing `Delete permanently` button, if the ajax
request response is failed the media attachment is removed from the list.
Steps to reproduce:
1. Add `pre_delete_attachment` filter in your theme's `functions.php` to
prevent the delete attachment operation.
{{{
add_filter( 'pre_delete_attachment', function ( $delete, $attachment ) {
return false;
}, 10, 2 );
}}}
2. Go to Media (grid mode) `https://example.com/wp-
admin/upload.php?mode=grid`
3. Click on any attachment. (The modal will open)
4. Click on `Delete permanently` button
- This will remove the attachment from grid list.
- If you check the Ajax request the response is 0
5. After done, reload the page. (The image is still there)
**Expected Result:**
If the media cannot be deleted or the response is failed, the Attachment
should be there. It should not be removed.
**Actual Result:**
If the media cannot be deleted or the response is failed, the Attachment
is getting removed from the list.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55158>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list