Make WordPress Core

Opened 9 years ago

Closed 7 years ago

#31401 closed defect (bug) (fixed)

wp-cron.php header comments confused or confusing

Reported by: gbell12's profile gbell12 Owned by: drewapicture's profile DrewAPicture
Milestone: 4.9 Priority: normal
Severity: normal Version: 2.6
Component: Cron API Keywords: dev-feedback has-patch
Focuses: docs Cc:


The header for wp-cron.php says:

WordPress Cron Implementation for hosts, which do not offer CRON or for which
the user has not set up a CRON job pointing to this file.

That's nonsensical, I think. It should say:

WordPress cron implementation to be called directly (e.g. via wget or curl) 
for sites which do not get enough visitors to properly trigger wp_cron in 

Attachments (1)

31401.patch (1.1 KB) - added by stevenlinx 8 years ago.

Download all attachments as: .zip

Change History (12)

#1 in reply to: ↑ description @kraftbj
9 years ago

  • Focuses docs added
  • Version changed from 4.1.1 to 2.6

What about: WordPress cron implementation able to be called directly or called automatically when ALTERNATE_WP_CRON is defined.

Some sites will want to replace the visit-trigger method with a standard server cron (via define('DISABLE_WP_CRON', true);) so the number of visitors isn't the issue.

Thanks for the report! The current language is confusing.

#2 @gbell12
9 years ago

Must I set DISABLE_WP_CRON if I am calling wp-cron.php directly? That is, must one replace the other? What happens if both visits and curl/wget are triggering cron?

I run server crons to my sites a few times a day, just as insurance, from a centralised server that doesn't want to do it every 5 minutes. I'd prefer if visits caused wp's cron to run more frequently, which means leaving DISABLE_WP_CRON unset.

Is that OK and does that change your version of the comment?

#3 @SergeyBiryukov
9 years ago

Leaving DISABLE_WP_CRON unset should be OK, yes.

#4 @gbell12
9 years ago

Hmm - also spawn_cron in wp-includes/cron.php calls wp-cron.php.

I'm a unclear as to the division of labor between cron.wp and wp-cron.php. I'll go investigate before I suggest the next version of the comment wording.

#5 @swissspidy
8 years ago

  • Keywords needs-patch added

#6 @DrewAPicture
8 years ago

@dd32 Any chance you could provide some clarity here? I can see improving the header comments, but it would be good to have a good handle on best-practice for overriding cron at the host level.

This ticket was mentioned in Slack in #docs by morganestes. View the logs.

8 years ago

#8 @morganestes
8 years ago

  • Keywords dev-feedback added

8 years ago

#9 @stevenlinx
8 years ago

  • Keywords has-patch added; needs-patch removed


As discussed previously, there are two different needs here:

i) Ensuring WP Cron runs at a minimum of X number of times alongside the visit-trigger method (as @gbell12 desired)

ii) Replacing WP Cron altogether

I think the comment header can be better by clarifying how the users can perform each of these two.




..wp_cron in wp-includes/wp_cron.php

There is no wp-includes/wp_cron.php. It's wp-includes/cron.php.


Hmm - also spawn_cron in wp-includes/cron.php calls wp-cron.php. I'm a unclear as to the division of labor between cron.wp and wp-cron.php....

This is basically what each does:

/wp-includes/cron.php => contains the entire WordPress Cron API and the functions needed to schedule WP Cron tasks. This is more for internal calling (e.g. by plugins).

/wp-cron.php => performs the actual action of looping through each of the WP Cron tasks and executing them.

I've uploaded a patch.

#10 @DrewAPicture
7 years ago

  • Milestone changed from Awaiting Review to 4.9

#11 @DrewAPicture
7 years ago

  • Owner set to DrewAPicture
  • Resolution set to fixed
  • Status changed from new to closed

In 41276:

Docs: Improve the usefulness and accuracy of the file header for wp-cron.php.

Props stevenlinx for the initial patch.
Fixes #31401.

Note: See TracTickets for help on using tickets.