add link for running cron manually to devel block
dww - August 9, 2006 - 07:57
| Project: | Devel |
| Version: | 7.x-1.x-dev |
| Component: | devel |
| Category: | feature request |
| Priority: | normal |
| Assigned: | dww |
| Status: | closed |
Description
now that http://drupal.org/node/76958 hit core, it'd be trivial to add a link on the devel block to run cron manually. i think this would be handy for debugging hook_cron() stuff, without having to dig around in the admin pages to find the link.

#1
Attached is my attempt at this, "run cron" link calls drupal_cron_run() and set_message' the status, then redirects to the previous page (similar to how the "empty cache" link works).
#2
New patch using drupal_goto() insterad of header().
Please note: I haven't tested the code, nor the previous patch, I just opened the patch file and edited it.
#3
I couldn't get drupal_goto() to work properly, so I copied the redirect code from devel_cache_clear(). Also when using drupal_goto(), you'll get the devel_redirect_page if you have that enabled.
#4
How about his code then? (still not tested)
<?php/**
* Menu callback; runs cron manually, then redirects to the previous page.
*/
function devel_cron_run() {
if (drupal_cron_run()) {
drupal_set_message(t('Cron ran successfully'));
}
else {
drupal_set_message(t('Cron run failed'));
}
$referer = '';
$referer = referer_uri();
if (!empty($referer)) {
$referer = $base_url;
}
drupal_goto($referer);
}
?>
#5
no referer crap. thats what destination= is for
#6
i'm w/ moshe. please re-roll. thanks. ;)
#7
See http://drupal.org/files/issues/devel-DRUPAL-5.patch
#8
Committed that to DRUPAL-5, ported to D6 myself, and committed to HEAD. Attached is the D6 patch for posterity/reference.
#9
Automatically closed -- issue fixed for two weeks with no activity.