ideas
ideas copied to clipboard
Clean up revisions in a user-friendly manner
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.
Related https://github.com/WordPress/gutenberg/issues/3656, because hosts may want to help users clean their data up.
Yes, current Gutenberg behavior makes this very useful and needed.
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.
@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
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.
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>