Module hooks are not being invoked
tom friedhof - September 7, 2007 - 16:28
| Project: | CronPlus |
| Version: | 5.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | syscrusher |
| Status: | closed |
Description
When I go to the status page of cronplus I see that only the cronplus_houry hook is invoked. None of the other hooks ever get invoked. I've had the module installed since July. So far the daily, weekly, and monthly hooks have never been invoked.
On the status page it shows that I have modules implementing the hooks, the hooks just never get invoked.

#1
The logic in the module for executing the different cron hooks was based off the last time hook_cron was run, not against the last time the particular hook was run (i.e. cronplus_hourly, cronplus_daily, cronplus_weekly).
I've written a patch to do the comparisons against the last time a particular hook was called.
-Tom Friedhof
#2
Not sure this patch could work? The new variables are never set anywhere.
+ $cronplus_hourly_last = intval(variable_get('cronplus_hourly_last', 0));+ $cronplus_daily_last = intval(variable_get('cronplus_daily_last', 0));
+ $cronplus_weekly_last = intval(variable_get('cronplus_weekly_last', 0));
+ $cronplus_monthly_last = intval(variable_get('cronplus_monthly_last', 0));
+ $cronplus_yearly_last = intval(variable_get('cronplus_yearly_last', 0));
#3
It's being set with variable_set($function_name .'_last', $now); on the 5th line of the function below:
function cronplus_invoke_hook($period, $now, $last_cron) {$now_fmt = gmdate('Y-m-d H:i:s', $now);
$function_name = 'cronplus_'. $period;
$last_this = variable_get($function_name .'_last', 0);
variable_set($function_name .'_last', $now);
watchdog('cronplus', t('Processing %period cron for %d UTC, calling {module}_%func() for all modules', array('%d' => $now_fmt, '%period' => t($period), '%func' => $function_name)), WATCHDOG_NOTICE);
@module_invoke_all($function_name, $now, $last_cron, $last_this);
@module_invoke_all('cronplus', $period, $now, $last_cron, $last_this);
}
#4
Ah, indeed... Could of sworn I searched on variable_set, but I should look closer. +1 on patch and thanks.
This is an indispensable little module, please commit this diff and the now_weekday patches so I can move it out of my custom folder. :)
#5
The patch is applied to the Drupal 5 version and also to the new Drupal 6 port. Many thanks, and sorry for the slow response. I've been really busy porting other modules to D6 lately.
#6
Automatically closed -- issue fixed for two weeks with no activity.