The update module check drifts later every cron run

Created on 25 April 2011, over 13 years ago
Updated 22 September 2023, about 1 year ago

I enabled the update feature that emails me whenever the site has an update available. I noticed that the time the email gets sent is always incremented by one cron run. For example, I have cron running hourly, so if there are updates needed it will email me at 8am, the next day at 9am, the next day at 10am, etc. But, based on the math, whatever interval cron runs at the email will likely always be one run later.

In hook_cron, the if statement requires the current time to be greater than interval (in my case, 24hrs). If it is exactly 24hrs, it will not pass.

function update_cron() {
  $frequency = variable_get('update_check_frequency', 1);
  $interval = 60 * 60 * 24 * $frequency;
  // Cron should check for updates if there is no update data cached or if the
  // configured update interval has elapsed.
  if (!_update_cache_get('update_available_releases') || ((time() - variable_get('update_last_check', 0)) > $interval)) {
    update_refresh();
    _update_cron_notify();
  }
}

Also, 'update_last_check' is set in _update_refresh(), after some work is done. You only need enough time between a cron run and the setting of 'update_last_check' for a second to turn over to guarantee this not running at the same time.

In my install, I moved the variable_set for 'update_last_check' from _update_refresh() to the first thing inside this if, and change the operator to >= (as the difference more often ends up exactly zero). It has been working for several days, sending the update email at the same time.

Also, it would be nice if there was a setting to say exactly when to send email updates: ✨ Allow defining when to send update alert emails Active .

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
UpdateΒ  β†’

Last updated 2 days ago

  • Maintained by
  • πŸ‡ΊπŸ‡ΈUnited States @tedbow
  • πŸ‡ΊπŸ‡ΈUnited States @dww
Created by

πŸ‡ΊπŸ‡ΈUnited States davidhernandez USA

Live updates comments and jobs are added and updated live.
  • Needs manual testing

    The change/bugfix cannot be fully demonstrated by automated testing, and thus requires manual testing in a variety of environments.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024