Make WordPress Core

Opened 2 years ago

#55556 new defect (bug)

WP cron daily issue

Reported by: liedekef's profile liedekef Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Cron API Keywords:
Focuses: Cc:

Description

In wordpress, a day is defined as having 24 hours:

wp-includes/default-constants.php: define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );

but that doesn’t take summer/winter time into account of course.
While it is being stated above the definition that these values are approximate and are provided for convenience, the DAY_IN_SECONDS is being used in the “daily” cron definition. This means - in case of DST - if you plan something to happen daily at midnight (say membership status recalc, half of the year it will happen one hour later/earlier (depending on the day you planned it initially).
So, in order to be sure something happens daily “as soon as the new day starts”, you need to plan it at 01:00 at the earliest to be sure it is always on the same day (in case of DST).
Since the fixed wp schedules are in fact “fixed”, why not have them calculate “daily” as the DateTime function “+1 day”? The same goes for weekly, monthly, yearly. The basic schedules could even be thrown away and WP could e.g. translate 'daily' to '+1 day' on the fly.

I know WP cron doesn’t run exactly the moment you want it (unless you use system cron), but if running something “daily” at around midnight and it causes it to be ran at 23:00 instead, you might be giving people an extra free day entrance (again for memberships).

Moreover, getting rid of "schedules" and moving cron to its own database table would be even better (planning a recurring action should not require the need for a schedule definition via a filter, but use "last executed time" + the recurrence definition in datetime notation as a cron-definition). But this last remark is a whole other discussion, so not for this issue (but I would be willing to invest time in this to help develop it).

Change History (0)

Note: See TracTickets for help on using tickets.