wp/wp-cron.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
--- a/wp/wp-cron.php	Tue Jun 09 11:14:17 2015 +0000
+++ b/wp/wp-cron.php	Mon Oct 14 17:39:30 2019 +0200
@@ -1,7 +1,14 @@
 <?php
 /**
- * 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.
+ * A pseudo-CRON daemon for scheduling WordPress tasks
+ *
+ * WP Cron is triggered when the site receives a visit. In the scenario
+ * where a site may not receive enough visits to execute scheduled tasks
+ * in a timely manner, this file can be called directly or via a server
+ * CRON daemon for X number of times.
+ *
+ * Defining DISABLE_WP_CRON as true and calling this file directly are
+ * mutually exclusive and the latter does not rely on the former to work.
  *
  * The HTTP request to this file will not slow down the visitor who happens to
  * visit when the cron job is needed to run.
@@ -34,6 +41,8 @@
  * @ignore
  * @since 3.3.0
  *
+ * @global wpdb $wpdb WordPress database abstraction object.
+ *
  * @return string|false Value of the `doing_cron` transient, 0|false otherwise.
  */
 function _get_cron_lock() {
@@ -64,7 +73,9 @@
 if ( isset($keys[0]) && $keys[0] > $gmt_time )
 	die();
 
-$doing_cron_transient = get_transient( 'doing_cron');
+
+// The cron lock: a unix timestamp from when the cron was spawned.
+$doing_cron_transient = get_transient( 'doing_cron' );
 
 // Use global $doing_wp_cron lock otherwise use the GET lock. If no lock, trying grabbing a new lock.
 if ( empty( $doing_wp_cron ) ) {
@@ -79,7 +90,10 @@
 	}
 }
 
-// Check lock
+/*
+ * The cron lock (a unix timestamp set when the cron was spawned),
+ * must match $doing_wp_cron (the "key").
+ */
 if ( $doing_cron_transient != $doing_wp_cron )
 	return;