[wp-trac] [WordPress Trac] #47868: wp_delete_attachment returning successfully, deleting all DB data, but NOT deleting files, and NOT returning false

WordPress Trac noreply at wordpress.org
Mon Aug 19 20:34:03 UTC 2019


#47868: wp_delete_attachment returning successfully, deleting all DB data, but NOT
deleting files, and NOT returning false
--------------------------+------------------------------
 Reporter:  Jossnaz       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by Jossnaz):

 Replying to [comment:2 donmhico]:

 maybe I should clarify. This is about `wp_delete_attachment` never
 returning false, even if no files are deleted. Try this, upload a media to
 wordpress. Lets call it myimage.png.
 now go to the wordpress DB and run

 {{{

 SELECT *
 FROM  `wp_postmeta`
 WHERE  `meta_value` LIKE  '%myimage%'

 }}}


 delete that entry or damage it otherwise somehow. Not all plugins and
 themes create proper wp_postmeta entries, right?

 now if you call `wp_delete_attachment` on that attachment, it will delete
 the DB entries, but not the file and it will not return false. It deleted
 something somehow a little bit, but doesnt let the programmer know that
 something happened a little bit but not really. Just imagine you have a
 couple thousand slightly damaged files in your wordpress DB, you run this
 function, never returns false or throws an error, then all DB entries are
 gone, and all files are still there.

 Bad.

 let me know if you need further explanation

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47868#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list