Skip to content

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

Closed

Description

@janw-me

Just a way to delete/clear all scheduled cron events.

Activity

  1. changed the title [-]Suggestion, add a --all flag[/-] [+]Suggestion, add a --all flag to wp cron delete[/+] on Dec 3, 2018
  2. added
    command:cron-event-delete
    on Dec 3, 2018
  3. swissspidy commented on Dec 3, 2018

    @swissspidy
    Member

    Couldn't you just use wp cron event list --fields=hook --format=csv | wp cron event delete?

    This better aligns with the WP-CLI project's philosophy: https://make.wordpress.org/cli/handbook/philosophy/#composability-is-always-a-good-idea

  4. janw-me commented on Dec 4, 2018

    @janw-me
    MemberAuthor

    The workaroud I used was just clear the option (I know that's not foolproof if you use alternate crons)

    Composability is nice mainly for wp post so you can do some pre filtering. Of if you want to run all wordfence crons or something like that.
    Implementing a --all will not break that. It's just an extra function that's easier.

    Also wp cron event run --all exists. Most of the wp plugin * and wp transient * have the --all flag.

  5. schlessera commented on May 30, 2022

    @schlessera
    Member

    @swissspidy I don't think your workaround would work, as the wp cron event delete command only accepts a single hook. You'd have to combine this with xargs to run multiple delete commands instead.

    This then brings us to the reason why we should have a change here either way, as we'd want to avoid unnecessarily running multiple instances of WP-CLI if it is pretty straight-forward to do so.

    In this case, that would mean to either accept multiple <hook> arguments as a variadic argument, or to provide something like --all instead.

    Given what we have with other commands, and to stay consistent, I'd even suggest providing both.

    This is less about removing composability, as it is about making an input argument "expressive" enough. So we're not adding new functionality to wp cron event delete, we're ensuring that the <hook> argument can be used for any combination of hooks you might want to delete: one hook, multiple hooks, all hooks.

    Does that make sense, especially as it relates to the project's philosophy?

  6. swissspidy commented on May 30, 2022

    @swissspidy
    Member

    Sure, it does 👍

  7. Mike-Hermans commented on Jun 2, 2022

    @Mike-Hermans
    Contributor

    I'll be picking up this issue today.

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

Metadata

Metadata

Assignees

Labels

command:cron-event-deletegood-first-issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions