ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Clean up revisions in a user-friendly manner

Open danielbachhuber opened this issue 6 years ago • 5 comments

On larger sites, there may be a large number of revisions in the database, causing some amount of bloat. The "easy" way to clean up revisions is to delete all of them. This isn't terribly helpful to the end user, because they may want to keep some revisions around.

It would be helpful to have a revision cleanup command that deleted revisions according to some user-friendly algorithm. For instance, ensure at least a few revisions (spread across the revision timeline) are kept per-post.

danielbachhuber avatar Apr 09 '18 18:04 danielbachhuber

Related https://github.com/WordPress/gutenberg/issues/3656, because hosts may want to help users clean their data up.

danielbachhuber avatar Apr 09 '18 18:04 danielbachhuber

Yes, current Gutenberg behavior makes this very useful and needed.

schlessera avatar Apr 10 '18 20:04 schlessera

I like the idea of "thinning out" revisions.

This could be done on a static period basis, for example retaining one revision per month, or it could be done according to the age of the post, for example retaining ten revisions from the history of the post. Cleaning out revisions made before the post was published would help, too.

johnbillion avatar Aug 26 '18 13:08 johnbillion

@schlessera @danielbachhuber

I am about to start work on this but, a bit confused with the command structure.

I am thinking following command structure. Please let me know your thoughts.

(1) wp post revision list (Display all revisions) (2) wp post revisions (Display revision of particular post) (3) wp post revision delete (Keeping only 10 most recent revisions and removing remaining revisions)

As @johnbillion already explain, I think we can keep 10 most recent revisions.

I am also thinking for flags like --clear-all which will remove all revision of post or --keep-only=5 which will keep only 5 recent revisions of posts.

Do we also need restore or diff flags? Like mentioned here.

abhijitrakas avatar Jun 12 '19 12:06 abhijitrakas

I think the following command structure makes sense:

  • wp post revision list <post-id> [--latest[=<limit>]] [--earliest[=<limit>]] --latest would sort chronologically with the latest one first. --latest=5 would limit the list of latest revisions to the 5 most recent. --earliest would sort chronologically with the earliest one first. --earliest=5 would limit the list of earliest revisions to the 5 most ancient.
  • wp post revision get <revision-id>
  • wp post revision delete [<revision-ids>...]
  • wp post revision prune [<post-ids>...] [--latest=<limit>] [--earliest=<limit>] If <post-ids> is provided, the --latest and --earliest flags apply to individually to these posts only. If <post-ids> is not provided, the --latest and --earliest flags apply to all posts individually (i.e. wp post revision prune --latest=5 will delete all but the latest 5 revisions for each post)
  • wp post revision restore <revision-id>
  • wp post revision diff <starting-revision-id> <ending-revision-id>

schlessera avatar Sep 11 '19 10:09 schlessera