Giter Site home page Giter Site logo

stevegrunwell / revision-strike Goto Github PK

View Code? Open in Web Editor NEW
17.0 4.0 4.0 317 KB

Periodically purge old post revisions via WP Cron.

Home Page: http://wordpress.org/plugins/revision-strike

License: MIT License

PHP 93.89% Shell 0.95% JavaScript 0.85% Gherkin 4.30%
wordpress wordpress-plugin post-revisions wp-cli wp-cron

revision-strike's Introduction

๐Ÿ‘‹ Hello, there!

I'm Steve, and I love building tools to help people build better software.

By day, I'm a Staff Software Engineer at Mailchimp, improving the way we handle audience information and our general involvement in the PHP ecosystem.

PHP is my bread-and-butter, and I love building out SaaS and other products using Laravel. I'm also a WordPress plugin author and core contributor, but my real passion is building code quality tools; it shouldn't come as any surprise that I've spent a lot of time working with CI/CD pipelines and all of the tooling that gets run as part of them.

I'm also a regular conference speaker (or at least was, pre-pandemic), so you may have met me at any number of PHP, WordPress, or other software-related events.

You can learn more about me over at stevegrunwell.com, follow me on Mastodon, or connect with me on LinkedIn.

revision-strike's People

Contributors

pereirinha avatar petenelson avatar stevegrunwell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

revision-strike's Issues

--post_types option for CLI

Issue #2 added the revisionstrike_post_types filter, but this same functionality should be available in the WP-CLI interface for the plugin.

Add a "strike all" option

For initial installations, clicking "Strike Revisions" over and over with high numbers is a pain. There should be a "clean up everything to this point" option; it won't be used often, but will help people get up and running with the plugin immediately.

This feature should be accessible via Tools > Revision Strike and the WP-CLI command.

Add post type options to the Tools page

There's a filter to change what post types are struck on cron and the --post_type flag on the WP-CLI command, so the Tools โ€บ Revision Strike page should probably have a way to select post types.

Default values should be derived from the aforementioned revisionstrike_post_types filter.

Wording choice: "Minimum post age" may confuse users.

It may confuse some users, or perhaps just me, to see "Minimum post age" when selecting the threshold for post age. It almost seems more like Maximum post age. But perhaps something more like "Post age threshold" will be more obvious.

Just a thought. Thanks for this plugin!

Update Composer dependencies

The Composer dependencies are way out of date, especially WP_Mock. These should be brought up-to-speed and the tests refactored accordingly.

Filter to set cron limit

Right now the WP Cron event is always clearing out a maximum of 50 post revisions. On larger sites that produce more than 50 posts a day, the percentage of revisions will never decrease, necessitating manual runs of strike().

Either a filter or setting should be introduced to allow this number to be raised. To mitigate performance concerns of running queries for 1000+ revision IDs at a time, perhaps the strike() method should also be rewritten to chunk IDs.

Tools > Strike Revisions page

Running on WP Cron is great, but for users who want on-demand striking but either lack access or the knowhow to use the CLI tool should have a way to run Revision Strike from within the WordPress admin panel.

Behat feature tests

Since we're making changes in the WordPress database, I'd feel a lot more comfortable if there were integration tests (Behat) as well as the PHPUnit tests that are already in place.

Chunk strike requests

This was originally mentioned in #13 and would benefit #14 as well, but calls to strike() should be chunked after a certain point so we're only querying a limited number of revision IDs at once but could effectively say "delete a million revisions".

Automate updates to the .pot file

Whether it's a Grunt task, a pre-commit hook, or something else it should be easy to re-generate languages/revision-strike.pot without having to worry about the WordPress i18n tools picking up on the vendor/ directory or other development dependencies.

Add "Strike All" section to Tools page

Note: This was originally part of #14, but I wanted to get 0.2 out on-time due to a client need, so the non-WP-CLI implementation is getting bumped to 0.3.

Add the "Strike All" features currently available via wp revision-strike clean-all to the Tools โ€บ Revision Strike page. To prevent timeouts, this feature might be best served by WP Async Task, then trigger a notification when the strike is complete.

Statistics on Tools page

It could be kind of cool to get some basic statistics on the Tools > Revision Strike page with information like "Your posts table currently has N revisions on posts published at least D days ago. That's P% of your database!"

This info might also be useful for the CLI tool to access.

Bump "Tested up to" version

Latest changes have been made against WP Trunk (4.6), so the WordPress.org readme.txt file should be updated to reflect that.

Generate .pot file

The plugin should be ready to accept translations from the get-go, so don't launch without the .pot file and proper loading.

Add 'Keep' option

Already working on a PR for this, but it would be handy to be able to keep a minimum number of revisions for a post. In some instances, it's handy to be able to look at post that has passed the days back setting and still be able to see at least the past couple of revisions.

revisionstrike_post_types filter not being called

From our discussion on Slack, working on a fix for the revisionstrike_post_types not being called. This is occurring because the code is checking for a null value in $args['post_type'] but that value is never null due to the defaults in the plugin.

After applying the fix locally and testing the filter, I found the syntax for the SQL statement is incorrect (see below), so the PR will include a fix and test for that as well.

SELECT r.ID FROM wp_posts r LEFT JOIN wp_posts p ON r.post_parent = p.ID WHERE r.post_type = 'revision' AND p.post_type IN ('post\', \'page') AND p.post_date < '2016-05-23' ORDER BY p.post_date ASC LIMIT 50

Filter eligible post types

Right now, Revision Strike is only cleaning up revisions on the "Post" post type. There should be a filter in the plugin that can alter the post types to be cleaned.

PHP Codesniffer

It would be nice to have PHP Codesniffer config in place and running along with Travis so that pull requests can be checked for coding standards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.