Skip to content

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

@janw-me

Description

@janw-me

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).

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions