Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
function subscription_cron(), lines 260 to 265:
$last_daily = floor(variable_get('subscription_last_daily', 0) / (60 * 60 * 24) );
if ( floor($now / (60 * 60 * 24)) > $last_daily) ) {
subscription_trigger(_subscription_invoke_cron($last_daily, $now), true);
}
variable_set('subscription_last_daily', $now);
This is wrong in two ways:
- if subscription_trigger() is invoked, $last_daily actually is not the time of the last call, but the time of the last call divided through (60 * 60 * 24), alas something around 13.180, which - interpreted as time in _subscription_invoke_cron() - means 13.180 seconds since 1.1.1970, which is still January 1st 1970. Therfore, this function always will return all content when triggered.
- Even if $last_daily would be treated correctly, it would only return content created between the last cron call and $now. This is because $last_daily is set to $now on each cron, say every hour for example. $last_dailyl should only be set, if a digist is send.
This is how the code should look like:
$last_daily = variable_get('subscription_last_daily', 0);
if ( floor($now / (60 * 60 * 24)) > floor($last_daily / (60 * 60 * 24)) ) {
subscription_trigger(_subscription_invoke_cron($last_daily, $now), true);
variable_set('subscription_last_daily', $now);
}