Hi all!
This is the first patch that I'm making, so I've started small, with a simple yet useful feature: a link to run cron manually. Do Drupal really need this feature? Well;
Sometimes one doesn't want to wait for 'real' cron to be run since a) the site is at a shared host that doesn't allow cron runs very often/at all b) one is very impatient/needs it quickly
It's rather lightweight and this feature could IMO be hard for a 3rd-party developer to implement among the cron settings.
Besides /admin/settings/cron-status is very empty at the moment.
(http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/forngren/cron...)
Cheers Johan Forngren
Comment | File | Size | Author |
---|---|---|---|
#25 | cronmanually.patch_9.txt | 7.77 KB | dww |
#24 | cronmanually.patch_8.txt | 8.25 KB | forngren |
#19 | cronmanually.patch_7.txt | 8.4 KB | dww |
#18 | cronmanually.patch_6.txt | 8.21 KB | forngren |
#16 | cronmanually.patch_5.txt | 7.69 KB | forngren |
Comments
Comment #1
FiReaNGeL CreditAttribution: FiReaNGeL commentedSounds like a neat addition to Drupal Core; it would help me with testing on my desktop in WAMP as I can't setup cron easily (windows box etc).
Comment #2
forngren CreditAttribution: forngren commentedComment #3
dww+1 in principle. my only concern is that once you click on the "manually" link, you go directly to cron.php (the intention) which returns no data (by design) and all you see is a blank page with no indication that anything happened. not sure if the solution is to just explain this in the text with some additional instructions about what to expect, or to change cron.php to at least print out some basic output (maybe if there's a ?verbose=true argument or something) and then this link would be changed to use that, too.
however, i think 1 of these 2 changes should happen before this goes in, which is why i'm setting this to "needs work". also, i'm attaching a new patch that removes an unnecessary newline, and that is build from drupal root (the top-level "drupal" directory, not from inside modules/system) since that's the recommended way to roll patches against core. ;) so, my patch isn't ready, either, it's just here to help forngren see what i'm talking about...
overall, thanks for the patch, i think this will be a good improvement. it's certainly something i do manually a lot on my test sites already, so having a link on that page will be handy. which reminds me, maybe we should put a similar link in the devel.module's main devel block. ;)
Comment #4
dwwto clarify: cron.php had better *not* return any data by default, or it'll screw up the usual case. that's why i'm proposing an optional arg to specify you're running it manually and want some kind of output.
Comment #5
dwwupon further consideration, killes, fireangel and myself think providing this link directly is a bad idea. a properly secured site won't allow cron.php to be run from an external client, for example. it'd be better to provide a button that causes the drupal site to internally invoke cron.php via
drupal_http_request()
(see http://api.drupal.org/api/head/function/drupal_http_request for more on that). this would probably also solve the problem of displaying the blank page, since the form with this button could just redirect you back to the admin page once cron.php is done.good luck! ;)
-derek
Comment #6
forngren CreditAttribution: forngren commentedHere's a slightly improved patch;
Updated menu items
Updated help
I didn't use drupal_http_request, it didn't feel drupalisch enough, instead I borrowed some code from cron.php. Hey, it's GPL, so why not ;)
Comment #7
dww"why not?" b/c if any of that code from cron.php changes, someone has to remember to fix the copy in here, too. cut + paste coding is *never* a good idea. ;)
now's as good a time as any to learn the right way to do this. just read the link i posted before about drupal_http_request(). that's how i learned drupal's code. i started fixing stuff i wanted fixed, and people showed me better ways to solve things.
also, i don't think the menu description needs to mention manually running cron. most of your help text changes are good, but i think you went 10% too far. ;)
keep up the good work, and i'm sure this can make it in before the 4.8 code freeze...
Comment #8
forngren CreditAttribution: forngren commentedLatest patch.
I have, as suggested by dww, moved the cron function itself into cron.inc. Cron.php will still remain, it just includes cron.inc and calls drupal_cron_run();
Btw, documentation ain't good, but the patch should be working.
Comment #9
forngren CreditAttribution: forngren commentedForgot to set status
Comment #10
eaton CreditAttribution: eaton commentedJust tested and ran it; seems to be working well. +1 for the concept, haven't had time to review the code thoroughly.
Comment #11
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedlatest patch does not use drupal_http_request. This would break manual cron runs if you protect cron.oho with a file directive in your htaccess which limits access to a handfull of IPs.
Comment #12
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedSorry, not yet fully awake, you don't need to start a separate request if you simply call the function.
Comment #13
forngren CreditAttribution: forngren commentedThe same patch really, just added comments and some forgotten t()s.
Comment #14
forngren CreditAttribution: forngren commentedSame patch again, Eclipse included a .project file in the last one :(
Comment #15
forngren CreditAttribution: forngren commentedKeeping up with head.
Some poeple have asked why this patch is neccesary, why not just call cron.php with their borwser? a) A properly secured server does just allow cron.php requests from own IP b) it's easier for lazy people/drupal newbies if there's a link c) now can other modules use drupal_cron_run, eg devel.module
Besides if this get a positive review I think it's ready for RTBC, since it's rather small and not complicated i any way.
Comment #16
forngren CreditAttribution: forngren commentedUpdated the patch, moved all stuff from cron.inc to common.inc, as discussed with killer.
Comment #17
dwwdoesn't apply cleanly any more. :( the help text changes are now rejected from system.module (due to recent changes -- HEAD is a fast-moving target)... forngren, please re-roll with the latest HEAD, and i'll review and RTBC it. ;)
thanks,
-derek
Comment #18
forngren CreditAttribution: forngren commentedKeeping with HEAD. I hate that patches get old... :p
Comment #19
dww1 minor change to forngren's latest patch. if you click on the "manually" link from admin/settings/cron-status, you go to (and stay on) admin/settings/cron-status/cron. this seems counter-intuitive. it tells you that the last cron job ran 0 seconds ago. when you reload the page, it keeps telling you it was only 0 seconds ago, since it keeps re-running cron. ;) i'd rather you were sent back to admin/settings/cron-status once admin/settings/cron-status/cron is done. i added a single drupal_goto() and now i think it makes much more sense and works as folks would anticipate.
also, i changed the wording of "Cron ran unsuccessfully" to "Cron run failed" to be a little more visually obvious.
setting to needs review (so forngren and killes can comment on my goto), but i think this patch is RTBC.
thanks for getting this done, forngren! ;)
-derek
Comment #20
forngren CreditAttribution: forngren commentedI like those changes...
Comment #21
Dries CreditAttribution: Dries commentedCoding style needs work: incorrect spacing and indentation.
(Wouldn't it be nicer if we'd reuse the scrollbar widget for this? At least, you'd be able to see progress.)
Comment #22
dwwre: scrollbar -- that'd be a lot more code (i've seen how it works in update.php, and it's not trivial) for a relatively minor UI enhancement. if we go that route, we shouldn't put all that crap in common.inc, and instead create a cron.inc that's only conditionally included. also, we'd have to be careful *not* to output anything when invoked via cron.php (the usual case). manually running cron seems rare enough as it is, i'm not sure it's worth the trouble/bloat to add this functionality. but, if you're into it, i'm sure forngren will be happy to roll a new, even bigger patch. ;)
Comment #23
dwwp.s. sorry i missed the coding style -- i'm usually pretty good about that. ;)
Comment #24
forngren CreditAttribution: forngren commentedI looked at the code (with some help of code-style.pl) and could only spot one error; /modules/system/system.module:759: '(' -> ' (' : if(drupal_cron_run()) {
Otherwise I couldn't find any, although the coding standards are quite new to me and it's likely that I missed something. And about that scrollbar, no, I'm not gonna do it. Much pain, small gain.
Comment #25
dwwahh, i found some other indentation problems in system_cron_status() and a stray space at the end of a comment somewhere else. also, i changed the comment in cron.php back to what it was, since i think the original text was more clear than your version.
dries, if you're talking about the indentation for the
<ul>
list in the help page, sadly, there seems to be no consistent convention. node.module's help block does it exactly like how it is in this patch. menu.module does it differently (that could be my fault, in fact). ;) a quick sample of other core modules shows that most of them do it this way, and menu.module is the outcast...Comment #26
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD.
Comment #27
(not verified) CreditAttribution: commented