hook_cron_alter.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <p>The hook_cron_alter(&$hooks) allows you to change the cron hooks defined by hook_cron() and hook_cronapi().</p>
  2. <h3>Example</h3>
  3. <p>Change default rules for the Node modules cron hook and hi-jack system cron:</p>
  4. <pre>
  5. function hook_cron_alter(&$hooks) {
  6. $hooks['node_cron']['settings']['rules'] = array('0 * * * *');
  7. $hooks['system_cron']['module'] = 'mymodule';
  8. $hooks['system_cron']['callback'] = 'mymodule_new_system_cron';
  9. $hooks['system_cron']['file'] = drupal_get_path('module', 'mymodule') . '/mymodule.cron.inc';
  10. }
  11. </pre>
  12. <p>Example of the Node modules cron hook data:</p>
  13. <pre>
  14. (
  15. [unsafe] =>
  16. [description] => Default cron handler
  17. [module] => node
  18. [configure] =>
  19. [settings] => Array
  20. (
  21. [enabled] => 1
  22. [rules] => Array
  23. (
  24. [0] => * * * * *
  25. )
  26. [catch_up] => 300
  27. )
  28. [function] => node_cron
  29. [callback] => node_cron
  30. )
  31. </pre>
  32. <h3>Description of data structure</h3>
  33. <table border="1">
  34. <tr><th>Name</th><th>Description</th></tr>
  35. <tr><td>unsafe</td><td>If true, then the cron hook is considered unsafe, meaning that Ultimate Cron will not execute it. This value is set by Ultimate Cron when determining which hooks are unsafe. A hook is considered unsafe, if the function resides in a module with a weight lower than Ultimate Cron.</td></tr>
  36. <tr><td>description</td><td>The description of the cron hook, usally defined in hook_cronapi(). The core modules description are added through a hook_cron_alter() in Ultimate Cron.</td></tr>
  37. <tr><td>module</td><td>Name of the module in which the cron hook lives</td></tr>
  38. <tr><td>configure</td><td>Link to module settings page</td></tr>
  39. <tr><td>settings</td><td>Array with settings data, contains enabled, rules and catch_up by default, provided by Ultimate Cron</td></tr>
  40. <tr><td>function</td><td>Name of function for the cron hook. Note: This is unsafe to change</td></tr>
  41. <tr><td>callback</td><td>Name of callback to use when executing cron. This is set to the cron hooks function by default</td></tr>
  42. <tr><td>file</td><td>Path to file (including filename) where callback is defined.</td></tr>
  43. </table>