Opened 19 years ago
Closed 18 years ago
#2425 closed enhancement (fixed)
Pseudo-Cron
Reported by: | ryan | Owned by: | ryan |
---|---|---|---|
Milestone: | 2.1 | Priority: | normal |
Severity: | normal | Version: | 2.0.1 |
Component: | Administration | Keywords: | cron |
Focuses: | Cc: |
Description
Add a Pseudo-Cron implementation to WP core. Useful for handling future posts, scheduling backups, etc.
http://comox.textdrive.com/pipermail/wp-hackers/2006-February/004764.html
Attachments (5)
Change History (23)
#2
@
19 years ago
And along comes a second pass. A list of improvements:
- Spawns off with fsockopen like execute-pings.php (and works on CGI in testing as well!)
- Filters for adding schedules to schedule events by (And the ability for an action to continue on without problems when its schedule providing plugin has disappeared)
- Future-posting actually works in this cut
- A volunteer by me to write documentation and fix this up more in the future.
Feedback is appreciated.
#4
@
19 years ago
I prefer wp_schedule_event() to wp_schedule_new_event(). I think the new is implied. Any preferences?
#7
@
19 years ago
Ryan's DB_PASS + salt check didn't make it in.
wp-cron.php doesn't need ?time= time(), unless we want to be able to run cron against future times.
Also, typo in function name.
Patch attached for all the above.
#9
@
19 years ago
Actually, the md5 and dbcheck was left out intentionally, I don't understand why it would be there in the first place. An external script loading wp-cron.php has no negative side effects, it just fetches an option and not much more, crons aren't run unless their scheduled time has come. This way, I had planned with MarkJaquith to include a constant to disable auto-spawning of wp-cron.php and allow a real cron to fetch it.
Thanks for catching the fwrite though, old debugging stuff. And the typo as well, that was from me moving the functions under wp_ to keep consistant.
#10
@
19 years ago
Marty Malicious: "Bwah haha. I'll... run his... cros jobs for him...."
Good call.
#11
@
19 years ago
With the NST about, this may show up as a vulnerability, I can see it now:
========== WordPress 2.1 Remote Cron Exectuion ==========
Severity: CRITICAL!!!!1
WordPress 2.1 allow any users to run wp-cron.php which may run scheduled cron jobs on remote server.
this vuln has a few problems though
[1] The cron jobs have to be scheduled by an admin user
If you are an admin user, you can enable cron jobs that could potentially damage your install or users!!
Solution
wordpress/ $ rm wp-cron.php
#12
@
19 years ago
Anyways, now that that bit of halarity is over, here's a fix for just that typo mdawaffe pointed out.
#15
@
19 years ago
WARNING: (MOSTLY TO KEEP PODZ HAPPY)
masquerade's above post was a joke. Don't take it seriously.
Oh, and masq, you forgot all the "l0lz!!11" and "h3h" and "gr33ts".
#16
@
18 years ago
Could someone please document how this works in general, either here or in the codex (and also point out since it's named wp-cron that it has absolutely in common with the plugin by the same name).
So far all I have observed/learned is that in 2.1 wp-cron is periodically calling wordpress back through the web at regular intervals (and therefore messing up my stats, quite annoying).
I'd definitely like to keep it's functionality for other plugins to hook into, but admin with enough experience should be able to setup a real cron to call it internally via php instead of an external web call.
remove_action('init', 'wp_cron');
will apparently disable it's web based self-call
Now how about some example code and suggested periodic time frame for a real cron to call it?
I'll get us started with what little I know, on most cpanel servers, this will call a php file every 20 minutes (offset by 5 to avoid load from automated newsreaders set to the hour)
5,25,45 * * * * /usr/local/bin/php /home/accountname/public_html/wordpress/example.php
So what should I be calling instead of "example.php" ??
ps. why is this ticket labeled as defect when it's clearly an enhancement?
Pseudo-Cron Implementation from Owen and Ryan