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

wp cron event run --due-now doesn't respect doing_cron transient #27

Open
janw-me opened this issue Jun 20, 2018 · 2 comments
Open

wp cron event run --due-now doesn't respect doing_cron transient #27

janw-me opened this issue Jun 20, 2018 · 2 comments

Comments

@janw-me
Copy link
Member

janw-me commented Jun 20, 2018

I use wp cron event run --due-now as my production cron. Every 5 minutes. But it's a heavy cron. Sometimes it takes more then 5 minutes. When that happens some events get executed twice. Mostly sending emails.

I would suggest a --no-doubles flag or something like that to prevent the cron from doing hooks twice.

When the flag is set, wp-cli should check for the doing_cron transient like core does. And set it if it's starting. Like core does.

Relevant core code

Why is it doing things twice

At the start of a cron all tasks are gathered with _get_cron_array, events get deleted once the start. And the remaing cron array is still executed. And still in the DB list So after 5 minutes the new cron get also does a _get_cron_array and will get all events that the first cron also is still handling (and deleting as it goes).

@danielbachhuber
Copy link
Member

👍 Seems reasonable.

@schlessera
Copy link
Member

I think this should even be the default behavior. I wouldn't consider this a breaking change, I'd classify this as a bug: We're diverting from expected Core behavior.

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