Skip to content

Conversation

@Mike-Hermans
Copy link
Contributor

@Mike-Hermans Mike-Hermans commented Jun 2, 2022

Fixes #39 by making the command more consistent with the wp cron event run command.

It is now possible to delete multiple cron events at once by either:

  • Specifying multiple hooks that need to be deleted:
$ wp cron event delete wp_version_check wp_update_plugins
  • Delete all cron events that are due now
$ wp cron event delete --due-now
  • Delete all cron events at once
$ wp cron event delete --all

Since the selection process of the run and delete command is now the same, a separate function has been added to filter the required hooks (::get_selected_cron_events()).

danielbachhuber and others added 30 commits February 7, 2017 11:19
General improvements to the build process
Escape prefix when listing all tables with prefix
Display correct error when plugin update fails to update plugins
```
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing symfony/finder (v2.8.16)
  - Installing symfony/finder (v2.8.17)
    Loading from cache

  - Removing symfony/yaml (v2.8.16)
  - Installing symfony/yaml (v2.8.17)
    Downloading: 100%

  - Removing symfony/filesystem (v2.8.16)
  - Installing symfony/filesystem (v2.8.17)
    Loading from cache

  - Removing symfony/config (v2.8.16)
  - Installing symfony/config (v2.8.17)
    Downloading: 100%

  - Removing symfony/debug (v2.8.16)
  - Installing symfony/debug (v2.8.17)
    Downloading: 100%

  - Removing symfony/console (v2.8.16)
  - Installing symfony/console (v2.8.17)
    Downloading: 100%

  - Removing symfony/dependency-injection (v2.8.16)
  - Installing symfony/dependency-injection (v2.8.17)
    Downloading: 100%

  - Removing symfony/event-dispatcher (v2.8.16)
  - Installing symfony/event-dispatcher (v2.8.17)
    Loading from cache

  - Removing symfony/process (v2.8.16)
  - Installing symfony/process (v2.8.17)
    Downloading: 100%

  - Removing symfony/translation (v2.8.16)
  - Installing symfony/translation (v2.8.17)
    Downloading: 100%

  - Removing wp-cli/php-cli-tools (v0.11.1)
  - Installing wp-cli/php-cli-tools (v0.11.2)
    Downloading: 100%

Writing lock file
Generating autoload files
```
Update Composer dependencies (2/15/2017)
Remove XDebug from PHP runtime within Travis CI environment.
Cache Composer in scaffolded plugin `.travis.yml`
Issues 3817 Existing PDF previews not deleted on media regenerate.
By default, disable auto-commit and (unique and forefin) key checks.
Introduce skip-optimization flag to force old behavior.
@Mike-Hermans Mike-Hermans changed the title Delete multiple events Delete multiple events at once Jun 2, 2022
Copy link
Member

@janw-me janw-me left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the refactor.
The tests need a bit more work.

@danielbachhuber
Copy link
Member

@Mike-Hermans @janw-me How's this pull request coming along? Anything I can help with?

@Mike-Hermans
Copy link
Contributor Author

Hi @danielbachhuber

I was waiting on a response from @janw-me on the cron.feature test from the conversation above, and a new review based on the changes made.

@janw-me
Copy link
Member

janw-me commented Aug 11, 2022

Sorry, I didn't see the notification.
The last comment was just to check.
@Mike-Hermans his conformation was all we need.

Comment on lines 438 to 440
if ( empty( $args ) && ! Utils\get_flag_value( $assoc_args, 'due-now' ) && ! Utils\get_flag_value( $assoc_args, 'all' ) ) {
WP_CLI::error( 'Please specify one or more cron events, or use --due-now/--all.' );
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs safeguards for flag combinations that don't make sense.

  • If you provide hooks, the addition of --due-now or --all should throw an error.
  • Providing both --due-now and --all at the same time should throw an error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: these should also have there seperate test cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. I will fix this soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @schlessera

After seeing other tests break I realized it should be possible to select hooks and combine them with the --due-now parameter. Only hooks + --all and --due-now --all should be invalid.

@Mike-Hermans
Copy link
Contributor Author

Hi @schlessera

I've updated the code and tests. Hooks are now valid in combination with --due-now, as this was already possible on the 'run' command as well.

@danielbachhuber
Copy link
Member

Proceeding with wp-cli/wp-cli#5594 for this repository. I've captured this PR to https://gist.github.com/danielbachhuber/09504e7a7cdb1144c2e6162950d2f594 in case this PR is auto-closed or broken in some way.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion, add a --all flag to wp cron delete