Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
WP Plugins
Cron-Control
Commits
69661a58
Commit
69661a58
authored
Dec 12, 2016
by
Erick Hitter
Committed by
GitHub
Dec 12, 2016
Browse files
Merge pull request #74 from Automattic/develop
If an event has no callbacks hooked to its action, skip it
parents
6770a263
91fd1cd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
includes/class-events.php
View file @
69661a58
...
...
@@ -65,6 +65,19 @@ class Events extends Singleton {
continue
;
}
// Skip events that don't have any callbacks hooked to their actions, unless their execution is requested
if
(
false
===
has_action
(
$event
[
'action'
]
)
&&
!
apply_filters
(
'a8c_cron_control_run_event_with_no_callbacks'
,
false
,
$event
)
)
{
if
(
false
===
$event
[
'args'
][
'schedule'
]
)
{
wp_unschedule_event
(
$event
[
'timestamp'
],
$event
[
'action'
],
$event
[
'args'
][
'args'
]
);
}
else
{
$timestamp
=
$event
[
'timestamp'
]
+
(
isset
(
$event
[
'args'
][
'interval'
]
)
?
$event
[
'args'
][
'interval'
]
:
0
);
wp_reschedule_event
(
$timestamp
,
$event
[
'args'
][
'schedule'
],
$event
[
'action'
],
$event
[
'args'
][
'args'
]
);
unset
(
$timestamp
);
}
continue
;
}
// Necessary data to identify an individual event
// `$event['action']` is hashed to avoid information disclosure
// Core hashes `$event['instance']` for us
...
...
tests/includes/utils.php
View file @
69661a58
...
...
@@ -13,6 +13,9 @@ class Utils {
'args'
=>
array
(),
);
// Plugin skips events with no callbacks
add_action
(
'a8c_cron_control_test_event'
,
'__return_true'
);
if
(
$allow_multiple
)
{
$event
[
'action'
]
.
=
'_'
.
rand
(
10
,
100
);
}
...
...
Write
Preview
Supports
Markdown
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