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
401b58bb
Commit
401b58bb
authored
Feb 17, 2017
by
Erick Hitter
Browse files
Update existing purge command to remove legacy data left in CPT
parent
1fc22b9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/wp-cli/class-one-time-fixers.php
View file @
401b58bb
...
...
@@ -7,12 +7,12 @@ namespace Automattic\WP\Cron_Control\CLI;
*/
class
One_Time_Fixers
extends
\
WP_CLI_Command
{
/**
* Remove
corrupt
Cron Control data re
sulting from initial plugin deployment
* Remove Cron Control data
p
re
viously stored in a CPT
*
* @subcommand
remove-all-plugin-data
* @subcommand
purge-legacy-cpt-entries
* @synopsis [--batch-size=<batch-size>] [--dry-run=<dry-run>]
*/
public
function
purge
(
$args
,
$assoc_args
)
{
public
function
purge
_cpt
(
$args
,
$assoc_args
)
{
global
$wpdb
;
// Are we actually destroying any data?
...
...
@@ -25,17 +25,13 @@ class One_Time_Fixers extends \WP_CLI_Command {
// Provide some idea of what's going on
\
WP_CLI
::
line
(
__
(
'CRON CONTROL'
,
'automattic-cron-control'
)
.
"
\n
"
);
// Don't create new events while deleting events
\
Automattic\WP\Cron_Control\_suspend_event_creation
();
$count
=
(
int
)
$wpdb
->
get_var
(
$wpdb
->
prepare
(
"SELECT COUNT(ID) FROM
{
$wpdb
->
posts
}
WHERE post_type = %s;"
,
'a8c_cron_ctrl_event'
)
);
$count
=
$wpdb
->
get_var
(
$wpdb
->
prepare
(
"SELECT COUNT(ID) FROM
{
$wpdb
->
posts
}
WHERE post_type = %s;"
,
'a8c_cron_ctrl_event'
)
);
if
(
is_numeric
(
$count
)
)
{
$count
=
(
int
)
$count
;
if
(
$count
>
1
)
{
\
WP_CLI
::
line
(
sprintf
(
__
(
'Found %s total items'
,
'automattic-cron-control'
),
number_format_i18n
(
$count
)
)
.
"
\n\n
"
);
\
WP_CLI
::
confirm
(
__
(
'Proceed?'
,
'automattic-cron-control'
)
);
}
else
{
\
WP_CLI
::
error
(
__
(
'
Something went wrong
...aborting!'
,
'automattic-cron-control'
)
);
\
WP_CLI
::
error
(
__
(
'
No entries found
...aborting!'
,
'automattic-cron-control'
)
);
}
// Should we really destroy all this data?
...
...
@@ -99,15 +95,6 @@ class One_Time_Fixers extends \WP_CLI_Command {
}
}
while
(
true
);
// Remove the now-stale cache when actively run
if
(
!
$dry_run
)
{
wp_cache_delete
(
'a8c_cron_ctrl_option'
);
\
WP_CLI
::
line
(
"
\n
"
.
sprintf
(
__
(
'Cleared the %s cache'
,
'automattic-cron-control'
),
'Cron Control'
)
);
}
// Let event creation resume
\
Automattic\WP\Cron_Control\_resume_event_creation
();
// Fin
\
WP_CLI
::
success
(
__
(
'All done.'
,
'automattic-cron-control'
)
);
}
...
...
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