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

Cannot unschedule more than 100 events with a given hook #125

Open
johnbillion opened this issue Aug 16, 2023 · 0 comments
Open

Cannot unschedule more than 100 events with a given hook #125

johnbillion opened this issue Aug 16, 2023 · 0 comments
Labels

Comments

@johnbillion
Copy link
Member

Deleting all events with a given hook via wp cron event unschedule <hook> or wp_unschedule_hook( <hook> ) will only delete a maximum of 100 events. If there are more than 100 events with that hook then the remainder will not be deleted and the command will need to be run multiple times.

This problem was identified on a site with a runaway process that had scheduled thousands of events with the same hook name but different parameters. Unscheduling the events only unscheduled 100 at a time.

This is caused by the \HM\Cavalcade\Plugin\Connector\pre_clear_scheduled_hook function that's hooked into pre_clear_scheduled_hook which queries for a maximum of 100 jobs.

The fix would be to either repeat this query in a loop until there are no more matches, or to remove the limit on the query, although the latter risks exhausting memory if there's an exceptionally high number of jobs with that hook.

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

No branches or pull requests

1 participant