Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up revisions in a user-friendly manner #94

Open
danielbachhuber opened this issue Apr 9, 2018 · 5 comments
Open

Clean up revisions in a user-friendly manner #94

danielbachhuber opened this issue Apr 9, 2018 · 5 comments

Comments

@danielbachhuber
Copy link
Member

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
Copy link
Member Author

Related WordPress/gutenberg#3656, because hosts may want to help users clean their data up.

@schlessera
Copy link
Member

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

@johnbillion
Copy link

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.

@abhijitrakas
Copy link

@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.

@schlessera
Copy link
Member

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants