Make WordPress Core

Opened 8 months ago

Closed 5 months 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 8 months ago.
Return early if postmeta can't be deleted
25107.diff (539 bytes) - added by nacin 7 months ago.

Download all attachments as: .zip

Change History (11)

comment:1 jakubferenc8 months ago

#25108 was marked as a duplicate.

comment:2 jakubferenc8 months ago

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

comment:3 SergeyBiryukov8 months ago

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

c3mdigital8 months ago

Return early if postmeta can't be deleted

comment:4 c3mdigital8 months ago

  • Keywords has-patch added; needs-patch removed

comment:5 nacin7 months ago

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

nacin7 months ago

comment:6 nacin7 months 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.

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

comment:8 nacin6 months ago

  • Milestone changed from 3.7 to 3.8

comment:9 nacin5 months 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.