ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Identifying orphan data within WordPress

Open danielbachhuber opened this issue 7 years ago • 0 comments

A conglomeration of two tickets


Adding media diff to media command

We've put together a few functions here: https://github.com/DigitalTactics/wp-cli-mediadiff for listing what are likely to be orphan files (files on the file system in the uploads folder which don't (for whatever reason) have corresponding attachment entries - yes we know some plugins manage files here too which don't result in attachments hence the likely); we then have options to move these files to a trash folder for inspection/retention and/or then delete them permanently if appropriate.

From https://github.com/wp-cli/media-command/issues/6


Introduce subcommands to list/delete orphaned entities

WordPress offers dedicated APIs that are to be used for CRUD operations on the various core data structures. When deleting a comment via wp_delete_comment( $some_id_here, true ), WordPress takes care that all metadata for that comment gets automatically deleted as well. Great!

However, as we all know, people not always do what is right, and so it's not a rare situation that you have to face a database that is full of orphaned entries. Comment metadata for comments that no longer exist, comments for non-existing posts, or posts with parents that don't exist anymore.

With the new subcommands, you can easily spot orphans, and even delete them, if you want.

From https://github.com/wp-cli/entity-command/issues/28

danielbachhuber avatar Dec 15 '17 13:12 danielbachhuber