Ticket #2425 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

Pseudo-Cron

Reported by: ryan Assigned to: ryan
Priority: normal Milestone: 2.1
Component: Administration Version: 2.0.1
Severity: normal Keywords: cron
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

pseudo-cron.diff (2.3 kB) - added by ryan on 02/11/06 01:08:39.
Pseudo-Cron Implementation from Owen and Ryan
wp-cron.php (112 bytes) - added by ryan on 02/11/06 01:09:30.
wp-cron.php
cron2.diff (7.5 kB) - added by masquerade on 03/07/06 08:55:42.
2425.diff (1.6 kB) - added by mdawaffe on 03/07/06 22:59:39.
md5 check, don't need time (do we?), typo
typo.diff (380 bytes) - added by masquerade on 03/08/06 05:50:30.

Change History

02/11/06 01:08:39 changed by ryan

  • attachment pseudo-cron.diff added.

Pseudo-Cron Implementation from Owen and Ryan

02/11/06 01:09:30 changed by ryan

  • attachment wp-cron.php added.

wp-cron.php

02/11/06 02:25:20 changed by ryan

First pass.

[3512]

03/07/06 08:42:46 changed by masquerade

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.

03/07/06 08:55:42 changed by masquerade

  • attachment cron2.diff added.

03/07/06 08:56:42 changed by masquerade

Oh, forgot to mention, this needs a few other bugfixes applied to work that I've submitted patches for while writing this.

#2542 and #2537

03/07/06 21:45:08 changed by ryan

[3634]

I prefer wp_schedule_event() to wp_schedule_new_event(). I think the new is implied. Any preferences?

03/07/06 21:47:17 changed by davidhouse

+1 for name change.

03/07/06 22:34:20 changed by ryan

03/07/06 22:59:06 changed by mdawaffe

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.

03/07/06 22:59:39 changed by mdawaffe

  • attachment 2425.diff added.

md5 check, don't need time (do we?), typo

03/07/06 23:00:47 changed by mdawaffe

Ah yes - sorry. And that patch gets rid of an extraneous fwrite().

03/07/06 23:50:06 changed by masquerade

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.

03/08/06 00:56:25 changed by mdawaffe

Marty Malicious: "Bwah haha. I'll... run his... cros jobs for him...."

Good call.

03/08/06 01:03:40 changed by masquerade

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

03/08/06 05:50:14 changed by masquerade

Anyways, now that that bit of halarity is over, here's a fix for just that typo mdawaffe pointed out.

03/08/06 05:50:30 changed by masquerade

  • attachment typo.diff added.

03/08/06 05:52:27 changed by ryan

[3636]

I committed the entire patch. The salt doesn't hurt.

03/08/06 05:57:31 changed by ryan

Oops, we crossed in the mail. We can remove the salting if we don't want it.

03/08/06 08:10:53 changed by davidhouse

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".

08/19/06 06:49:28 changed by _ck_

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?

08/19/06 08:10:12 changed by JeremyVisser

  • type changed from defect to enhancement.

10/03/06 18:54:34 changed by mdawaffe

  • status changed from new to closed.
  • resolution set to fixed.

Closing this as fixed by the above and more. New cron issues should go into new tickets.

Masquerade, I agree about the salt. If it's still an issue, let's start a new ticket.