[wp-trac] [WordPress Trac] #55556: WP cron daily issue

WordPress Trac noreply at wordpress.org
Mon Apr 11 08:36:02 UTC 2022


#55556: WP cron daily issue
--------------------------+-----------------------------
 Reporter:  liedekef      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Cron API      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55556>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list