Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WP Plugins
Cron-Control
Commits
ddf19012
Commit
ddf19012
authored
Aug 03, 2017
by
Erick Hitter
Browse files
Rework how runner-disabling option is set, as it's used in very limited circumstances
parent
fa8a6afd
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/class-events.php
View file @
ddf19012
...
...
@@ -13,7 +13,6 @@ class Events extends Singleton {
const
LOCK
=
'run-events'
;
const
DISABLE_RUN_OPTION
=
'a8c_cron_control_disable_run'
;
private
$run_disabled
=
0
;
private
$concurrent_action_whitelist
=
array
();
...
...
@@ -28,33 +27,12 @@ class Events extends Singleton {
// Prime options and prepare environment as early as possible
$earliest_action
=
did_action
(
'muplugins_loaded'
)
?
'plugins_loaded'
:
'muplugins_loaded'
;
add_action
(
$earliest_action
,
array
(
$this
,
'prime_options'
)
);
add_action
(
$earliest_action
,
array
(
$this
,
'prepare_environment'
)
);
// Allow code loaded as late as the theme to modify the whitelist
add_action
(
'after_setup_theme'
,
array
(
$this
,
'populate_concurrent_action_whitelist'
)
);
}
/**
* Set initial options that control event behaviour
*/
public
function
prime_options
()
{
// Prime option to disable automatic execution
if
(
is_admin
()
||
(
defined
(
'WP_CLI'
)
&&
\
WP_CLI
)
||
false
!==
get_endpoint_type
()
)
{
add_option
(
self
::
DISABLE_RUN_OPTION
,
0
,
null
,
false
);
}
// Check if execution is disabled, or if timestamp has passed
$disabled
=
(
int
)
get_option
(
self
::
DISABLE_RUN_OPTION
,
0
);
if
(
$disabled
<=
1
)
{
$this
->
run_disabled
=
$disabled
;
}
elseif
(
$disabled
>
time
()
)
{
$this
->
run_disabled
=
$disabled
;
}
else
{
$this
->
update_run_status
(
0
);
}
}
/**
* Prepare environment to run job
*
...
...
@@ -497,7 +475,14 @@ class Events extends Singleton {
* @return int 0 if run is enabled, 1 if run is disabled indefinitely, otherwise timestamp when execution will resume
*/
public
function
run_disabled
()
{
return
$this
->
run_disabled
;
$disabled
=
(
int
)
get_option
(
self
::
DISABLE_RUN_OPTION
,
0
);
if
(
$disabled
<=
1
||
$disabled
>
time
()
)
{
return
$disabled
;
}
$this
->
update_run_status
(
0
);
return
0
;
}
/**
...
...
@@ -521,14 +506,7 @@ class Events extends Singleton {
return
false
;
}
$updated
=
update_option
(
self
::
DISABLE_RUN_OPTION
,
$new_status
);
if
(
$updated
)
{
$this
->
run_disabled
=
$new_status
;
return
true
;
}
return
false
;
return
update_option
(
self
::
DISABLE_RUN_OPTION
,
$new_status
);
}
}
...
...
Erick Hitter
@ethitter
mentioned in commit
f279543b
·
Nov 25, 2017
mentioned in commit
f279543b
mentioned in commit f279543b08e621621de748fc30ac0e050c1a9994
Toggle commit list
Erick Hitter
@ethitter
mentioned in commit
af281fa5
·
Nov 25, 2017
mentioned in commit
af281fa5
mentioned in commit af281fa5c0bd801d867828686e8a92bd83df570d
Toggle commit list
Erick Hitter
@ethitter
mentioned in commit
d9021f6e
·
Nov 25, 2017
mentioned in commit
d9021f6e
mentioned in commit d9021f6ec19273b35071adc3f8cb460dafb35975
Toggle commit list
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