WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#25107 closed defect (bug) (fixed)

Deleting files from Media Library when MySQL database locked

Reported by: jakubferenc Owned by: nacin
Milestone: 3.8 Priority: normal
Severity: major Version: 3.6
Component: Media Keywords: has-patch commit
Focuses: Cc:

Description (last modified by SergeyBiryukov)

While permamently deleting files uploaded to a post, I incidentally had set in the mysql config "innodb_force_recovery = 1" and therefore, as it is my understanding, the database was protected against any changes.

Files were, however, permamently deleted from the filesystem but kept in the databased and show in the media library, naturally without the associated image files.

Attachments (2)

25107.patch (573 bytes) - added by c3mdigital 5 years ago.
Return early if postmeta can't be deleted
25107.diff (539 bytes) - added by nacin 5 years ago.

Download all attachments as: .zip

Change History (11)

#1 @jakubferenc
5 years ago

#25108 was marked as a duplicate.

#2 @jakubferenc
5 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#3 @SergeyBiryukov
5 years ago

  • Description modified (diff)
  • Resolution invalid deleted
  • Status changed from closed to reopened

@c3mdigital
5 years ago

Return early if postmeta can't be deleted

#4 @c3mdigital
5 years ago

  • Keywords has-patch added; needs-patch removed

#5 @nacin
5 years ago

  • Milestone changed from Awaiting Review to 3.7
  • Owner set to nacin
  • Status changed from reopened to accepted

@nacin
5 years ago

#6 @nacin
5 years ago

  • Keywords commit added

We're ultimately not doing everything inside of an atomic transaction. So I think I prefer something like 25107.diff that specifically waits to see if the primary delete query is successful.

#7 @ocean90
5 years ago

An issue with 25107.diff could be, that deleting metadata works, but the primary delete query fails. This results in a post without any meta, like for image sizes, which means, that image_get_intermediate_size() will fail and the image files can't be deleted.

#8 @nacin
5 years ago

  • Milestone changed from 3.7 to 3.8

#9 @nacin
4 years ago

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

In 26543:

Return false from wp_delete_post() and wp_delete_attachment() if the DELETE is unsuccessful.

This prevents attachments from being deleted off disk when a DB is locked and the delete is otherwise unsuccessful.

fixes #25107.

Note: See TracTickets for help on using tickets.