Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WP Plugins
Cron-Control
Commits
206d8414
Commit
206d8414
authored
Feb 18, 2017
by
Erick Hitter
Browse files
Automatically fix Internal Events when their schedules change
parent
b75ff811
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/class-internal-events.php
View file @
206d8414
...
...
@@ -155,7 +155,9 @@ class Internal_Events extends Singleton {
}
/**
* Remove data related to how Core manages cron in the absence of this plugin
* Remove unnecessary data and scheduled events
*
* Some of this data relates to how Core manages Cron when this plugin isn't active
*/
public
function
clean_legacy_data
()
{
// Cron option can be very large, so it shouldn't linger
...
...
@@ -167,6 +169,38 @@ class Internal_Events extends Singleton {
}
else
{
delete_transient
(
'doing_cron'
);
}
// Confirm internal events are scheduled for when they're expected
$schedules
=
wp_get_schedules
();
foreach
(
$this
->
internal_jobs
as
$internal_job
)
{
$timestamp
=
wp_next_scheduled
(
$internal_job
[
'action'
]
);
// Will reschedule on its own
if
(
false
===
$timestamp
)
{
continue
;
}
$job_details
=
get_event_by_attributes
(
array
(
'timestamp'
=>
$timestamp
,
'action'
=>
$internal_job
[
'action'
],
'instance'
=>
md5
(
maybe_serialize
(
array
()
)
),
)
);
if
(
$job_details
->
schedule
!==
$internal_job
[
'schedule'
]
)
{
if
(
$timestamp
<=
time
()
)
{
$timestamp
=
time
()
+
(
1
*
\
MINUTE_IN_SECONDS
);
}
$args
=
array
(
'schedule'
=>
$internal_job
[
'schedule'
],
'args'
=>
$job_details
->
args
,
'interval'
=>
$schedules
[
$internal_job
[
'schedule'
]
][
'interval'
],
);
schedule_event
(
$timestamp
,
$job_details
->
action
,
$args
,
$job_details
->
ID
);
}
}
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment