Initialization
mrsecret - November 3, 2009 - 11:18
| Project: | Elysia Cron |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | gotheric |
| Status: | needs work |
Jump to:
Description
When defining a cron job via hook_cronapi as follows :
function mymodule_cronapi($op, $job = NULL) {
switch ($op) {
case 'list' :
return array(
'mymodule_index' => 'Some index routine'
);
break;
case 'rule' :
switch ($job) {
case 'mymodule_index' : return '15 1 * * *';
}
break;
case 'execute' :
switch ($job) {
case 'mymodule_index' :
mymodule_index_function();
break;
}
break;
}
}and then try to run the routine via "admin/build/cron/status" i am getting sucessful job execution, but in logs there is a message "could not find a function".
After doing some research, i've found that
function elysia_cron_execute_page($job = false) {
global $cron_completed, $cron_executing_job;
if (!$job) {
drupal_set_message(t('No job specified'), 'error');
drupal_goto('admin/build/cron');
}
...
}needs to have elysia_cron_initialize(); call, as follows:
function elysia_cron_execute_page($job = false) {
global $cron_completed, $cron_executing_job;
elysia_cron_initialize();
if (!$job) {
drupal_set_message(t('No job specified'), 'error');
drupal_goto('admin/build/cron');
}
...
}After this everything started to work perfectly.

#1
Hmm, interesting... i'll commit the fix soon!
Thanks for the report.
P.S. Just for information, you can use a more compact form of the declaration (avoiding the "case 'execute'"):
function mymodule_cronapi($op, $job = NULL) {
switch ($op) {
case 'list' :
return array(
'mymodule_index_function' => 'Some index routine'
);
break;
case 'rule' :
switch ($job) {
case 'mymodule_index_function' : return '15 1 * * *';
}
break;
}
}
function mymodule_index_function() {
...
}
#2
Yep, i know. That was just the case when the bug comes up.