[wp-trac] [WordPress Trac] #44818: cron: preventing duplicate events fails when the first event is too far in the past
WordPress Trac
noreply at wordpress.org
Thu Aug 23 14:22:06 UTC 2018
#44818: cron: preventing duplicate events fails when the first event is too far in
the past
-----------------------------+------------------------------
Reporter: bodohugobarwich | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Cron API | Version: 4.9.8
Severity: normal | Resolution:
Keywords: | Focuses:
-----------------------------+------------------------------
Comment (by bodohugobarwich):
Therefore my proposition would be a Function {{{wp_last_scheduled()}}}\\
which would look for the biggest timestamp for a given hook
{{{#!php
<?php
function wp_last_scheduled( $hook, $args = array() ) {
$crons = _get_cron_array();
$key = md5(serialize($args));
$lasttimestamp = 0;
if ( empty($crons) )
return false;
foreach ( $crons as $timestamp => $cron ) {
if ( isset( $cron[$hook][$key] ) )
if ( $timestamp > $lasttimestamp )
$lasttimestamp = $timestamp;
}
if ( $lasttimestamp > 0 )
return $lasttimestamp;
else
return false;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44818#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list