And that goes against all the documentation.
In elysia_cron_module_jobs(), the default options for each job are added, but 'callback' and 'arguments' rely on the $job key being an existing function. If I specify 'file' but not 'callback', the callback function I want to use hasn't been loaded yet, and callback gets set to {$module}_cronapi instead of $job.
Putting an include_once() in this function may not be the best idea, so perhaps what needs to happen is an update to the documentation, saying 'file' requires the 'callback' or the 'execute' $op for hook_cronapi().
Comments
Comment #1
gotheric commentedInteresting issue.
You're right, if someone declares a "file", and in the same file he declares the standard cron function (= a function named as the job name) without declaring the "callback" it doesn't work.
A solution to avoid the inclusion of "file" in elysia_cron_module_jobs() is to setting the default function not to "{$module}_cronapi", but to a new "croncall_proxy" function that, when called, includes the file and choose what to do.
I'll thing about it.
Thanks for the issue.
Comment #2
kala4ekComment #3
Island Usurper commentedSo last night I spent 4 hours wrestling with my debugger only to find this issue again. Imagine my surprise when I realize I wrote this issue in the first place! :-|
I think the way to fix this is not to check the callability when the jobs are collected, but when we need to execute them. Patch is forthcoming.
Comment #4
Island Usurper commentedI haven't tested this yet, but if someone sees any problems before I get to, here is the patch.
Comment #5
Island Usurper commentedInitial tests say it works for me.
Comment #6
kala4ekComment #8
kala4ekThanks, committed to latest dev.
Comment #9
imre.horjanLatest dev is broken after this commit:
http://cgit.drupalcode.org/elysia_cron/commit/?id=71c0b8d
These change seem to cause this error:
- include_once((!empty($_elysia_cron_settings[$job]['file path']) ? $_elysia_cron_settings[$job]['file path'] : drupal_get_path('module', $_elysia_cron_settings[$job]['module'])) . DIRECTORY_SEPARATOR . $_elysia_cron_settings[$job]['file']);
+ include_once !empty($_elysia_cron_settings[$job]['file path']) ? $_elysia_cron_settings[$job]['file path'] : drupal_get_path('module', $_elysia_cron_settings[$job]['module']) . DIRECTORY_SEPARATOR . $_elysia_cron_settings[$job]['file'];
If you define 'callback', 'file' and 'file path' in your cronapi hook, Elysia cron tryies to include empty filenames @ line 1448, and cron callback is not executed.
(2.3 works fine)
Comment #10
imre.horjanComment #11
Island Usurper commentedConcatenation of strings within and around the conditional operator is goofy. While the outermost parentheses for
include_onceweren't needed, the ones from the!empty()to theDIRECTORY_SEPARATORare.Comment #12
imre.horjanComment #13
imre.horjanSince the other patch is already merged, I've created a new one based on latest dev based on Island Usurper's suggestion.
Please check if the patch can be applied...it's exported from PHPStorm.
Comment #14
imre.horjanComment #16
kala4ekFixed it, also reformatted this ugly line into several lines, made it easy to understand.