{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/Cron-Control/pulls/comments/90992394","pull_request_review_id":11504422,"id":90992394,"diff_hunk":"@@ -0,0 +1,106 @@\n+<?php\n+\n+namespace Automattic\\WP\\Cron_Control\\CLI;\n+\n+class One_Time_Fixers extends \\WPCOM_VIP_CLI_Command {\n+\n+\t/**\n+\t * Remove corrupt Cron Control data resulting from initial plugin deployment\n+\t *\n+\t * eg.: `wp --allow-root cron-control remove-all-plugin-data --batch-size=15 --dry-run=true`\n+\t *\n+\t * @subcommand remove-all-plugin-data\n+\t */\n+\tpublic function purge( $args, $assoc_args ) {\n+\t\tglobal $wpdb;\n+\n+\t\t// Are we actually destroying any data?\n+\t\t$dry_run = true;\n+\n+\t\tif ( isset( $assoc_args['dry-run'] ) && 'false' === $assoc_args['dry-run'] ) {\n+\t\t\t$dry_run = false;\n+\t\t}\n+\n+\t\t// Provide some idea of what's going on\n+\t\t\\WP_CLI::line( __( 'CRON CONTROL', 'automattic-cron-control' ) . \"\\n\" );\n+\n+\t\t$count = $wpdb->get_var( $wpdb->prepare( \"SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_type = %s;\", 'a8c_cron_ctrl_event' ) );\n+\n+\t\tif ( is_numeric( $count ) ) {\n+\t\t\t$count = (int) $count;\n+\t\t\t\\WP_CLI::line( sprintf( __( 'Found %s total items', 'automattic-cron-control' ), number_format_i18n( $count ) ) . \"\\n\\n\" );\n+\t\t} else {\n+\t\t\t\\WP_CLI::line( __( 'Something went wrong...aborting!', 'automattic-cron-control' ) );\n+\t\t\treturn;\n+\t\t}\n+\n+\t\t// Should we really destroy all this data?\n+\t\tif ( ! $dry_run ) {\n+\t\t\t\\WP_CLI::line( __( 'This process will remove all CPT data for the Cron Control plugin', 'automattic-cron-control' ) );\n+\t\t\t\\WP_CLI::confirm( __( 'Proceed?', 'automattic-cron-control' ) );\n+\t\t\t\\WP_CLI::line( \"\\n\" . __( 'Starting...', 'automattic-cron-control' ) . \"\\n\" );\n+\t\t}\n+\n+\t\t// Determine how many batches this will take\n+\t\tif ( isset( $assoc_args['batch-size'] ) ) {\n+\t\t\t$page_size = max( 1, min( absint( $assoc_args['batch-size'] ), 500 ) );\n+\t\t} else {\n+\t\t\t$page_size = 250;\n+\t\t}\n+\t\t\\WP_CLI::line( sprintf( __( 'Processing in batches of %s', 'automattic-cron-control' ), number_format_i18n( $page_size ) ) . \"\\n\\n\" );\n+\n+\t\t$pages     = 1;\n+\t\t$page      = 1;\n+\n+\t\tif ( $count > $page_size ) {\n+\t\t\t$pages = ceil( $count / $page_size );\n+\t\t}\n+\n+\t\t// Let's get on with it\n+\t\tdo {\n+\t\t\t\\WP_CLI::line( \"\\n\\n\" . sprintf( __( 'Processing page %s of %s', 'automattic-cron-control' ), number_format_i18n( $page ), number_format_i18n( $pages ) ) . \"\\n\" );\n+\n+\t\t\t$items = $wpdb->get_results( $wpdb->prepare( \"SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type = %s LIMIT %d\", 'a8c_cron_ctrl_event', $page_size ) );\n+\n+\t\t\t// Nothing more to do\n+\t\t\tif ( ! is_array( $items ) || empty( $items ) ) {\n+\t\t\t\t\\WP_CLI::line( __( 'No more items found!', 'automattic-cron-control' ) );\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\t\\WP_CLI::line( sprintf( __( 'Found %s items in this batch' ), number_format_i18n( count( $items ) ) ) );\n+\n+\t\t\tif ( ! $dry_run ) {\n+\t\t\t\tforeach ( $items as $item ) {\n+\t\t\t\t\t\\WP_CLI::line( \"{$item->ID}, `{$item->post_title}`\" );","path":"includes/wp-cli/class-one-time-fixers.php","position":75,"original_position":75,"commit_id":"749be4798f36974bdd0f5705550e2d3d34696089","original_commit_id":"749be4798f36974bdd0f5705550e2d3d34696089","user":{"login":"nickdaugherty","id":1103700,"avatar_url":"https://avatars.githubusercontent.com/u/1103700?v=3","gravatar_id":"","url":"https://api.github.com/users/nickdaugherty","html_url":"https://github.com/nickdaugherty","followers_url":"https://api.github.com/users/nickdaugherty/followers","following_url":"https://api.github.com/users/nickdaugherty/following{/other_user}","gists_url":"https://api.github.com/users/nickdaugherty/gists{/gist_id}","starred_url":"https://api.github.com/users/nickdaugherty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickdaugherty/subscriptions","organizations_url":"https://api.github.com/users/nickdaugherty/orgs","repos_url":"https://api.github.com/users/nickdaugherty/repos","events_url":"https://api.github.com/users/nickdaugherty/events{/privacy}","received_events_url":"https://api.github.com/users/nickdaugherty/received_events","type":"User","site_admin":false},"body":"For the dry run, we should also print out each item id and title, so the runner can spot-check it for accuracy before committing to a real run.","created_at":"2016-12-06T01:00:51Z","updated_at":"2016-12-06T01:01:35Z","html_url":"https://github.com/Automattic/Cron-Control/pull/32#discussion_r90992394","pull_request_url":"https://api.github.com/repos/Automattic/Cron-Control/pulls/32","_links":{"self":{"href":"https://api.github.com/repos/Automattic/Cron-Control/pulls/comments/90992394"},"html":{"href":"https://github.com/Automattic/Cron-Control/pull/32#discussion_r90992394"},"pull_request":{"href":"https://api.github.com/repos/Automattic/Cron-Control/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/Cron-Control/pulls/32","id":96640602,"html_url":"https://github.com/Automattic/Cron-Control/pull/32","diff_url":"https://github.com/Automattic/Cron-Control/pull/32.diff","patch_url":"https://github.com/Automattic/Cron-Control/pull/32.patch","issue_url":"https://api.github.com/repos/Automattic/Cron-Control/issues/32","number":32,"state":"open","locked":false,"title":"Introduce CLI command to purge events","user":{"login":"ethitter","id":321503,"avatar_url":"https://avatars.githubusercontent.com/u/321503?v=3","gravatar_id":"","url":"https://api.github.com/users/ethitter","html_url":"https://github.com/ethitter","followers_url":"https://api.github.com/users/ethitter/followers","following_url":"https://api.github.com/users/ethitter/following{/other_user}","gists_url":"https://api.github.com/users/ethitter/gists{/gist_id}","starred_url":"https://api.github.com/users/ethitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethitter/subscriptions","organizations_url":"https://api.github.com/users/ethitter/orgs","repos_url":"https://api.github.com/users/ethitter/repos","events_url":"https://api.github.com/users/ethitter/events{/privacy}","received_events_url":"https://api.github.com/users/ethitter/received_events","type":"User","site_admin":false},"body":"From time to time, perhaps when retiring this plugin, it may be necessary to remove all of its data.","created_at":"2016-12-06T00:52:07Z","updated_at":"2016-12-06T01:01:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"500539fb2465331cf5b7662d06f995a9c58a7cbf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Automattic/Cron-Control/pulls/32/commits","review_comments_url":"https://api.github.com/repos/Automattic/Cron-Control/pulls/32/comments","review_comment_url":"https://api.github.com/repos/Automattic/Cron-Control/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/Cron-Control/issues/32/comments","statuses_url":"https://api.github.com/repos/Automattic/Cron-Control/statuses/749be4798f36974bdd0f5705550e2d3d34696089","head":{"label":"Automattic:add/cli-commands","ref":"add/cli-commands","sha":"749be4798f36974bdd0f5705550e2d3d34696089","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":72902182,"name":"Cron-Control","full_name":"Automattic/Cron-Control","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/Cron-Control","description":"A fresh take on running WordPress's cron system, allowing parallel processing","fork":false,"url":"https://api.github.com/repos/Automattic/Cron-Control","forks_url":"https://api.github.com/repos/Automattic/Cron-Control/forks","keys_url":"https://api.github.com/repos/Automattic/Cron-Control/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/Cron-Control/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/Cron-Control/teams","hooks_url":"https://api.github.com/repos/Automattic/Cron-Control/hooks","issue_events_url":"https://api.github.com/repos/Automattic/Cron-Control/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/Cron-Control/events","assignees_url":"https://api.github.com/repos/Automattic/Cron-Control/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/Cron-Control/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/Cron-Control/tags","blobs_url":"https://api.github.com/repos/Automattic/Cron-Control/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/Cron-Control/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/Cron-Control/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/Cron-Control/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/Cron-Control/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/Cron-Control/languages","stargazers_url":"https://api.github.com/repos/Automattic/Cron-Control/stargazers","contributors_url":"https://api.github.com/repos/Automattic/Cron-Control/contributors","subscribers_url":"https://api.github.com/repos/Automattic/Cron-Control/subscribers","subscription_url":"https://api.github.com/repos/Automattic/Cron-Control/subscription","commits_url":"https://api.github.com/repos/Automattic/Cron-Control/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/Cron-Control/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/Cron-Control/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/Cron-Control/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/Cron-Control/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/Cron-Control/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/Cron-Control/merges","archive_url":"https://api.github.com/repos/Automattic/Cron-Control/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/Cron-Control/downloads","issues_url":"https://api.github.com/repos/Automattic/Cron-Control/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/Cron-Control/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/Cron-Control/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/Cron-Control/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/Cron-Control/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/Cron-Control/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/Cron-Control/deployments","created_at":"2016-11-05T03:15:35Z","updated_at":"2016-11-28T22:01:20Z","pushed_at":"2016-12-06T00:52:07Z","git_url":"git://github.com/Automattic/Cron-Control.git","ssh_url":"git@github.com:Automattic/Cron-Control.git","clone_url":"https://github.com/Automattic/Cron-Control.git","svn_url":"https://github.com/Automattic/Cron-Control","homepage":null,"size":206,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"b75aa9f02fa3dc57fac6f02bc8fb8b9e661b574c","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":72902182,"name":"Cron-Control","full_name":"Automattic/Cron-Control","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/Cron-Control","description":"A fresh take on running WordPress's cron system, allowing parallel processing","fork":false,"url":"https://api.github.com/repos/Automattic/Cron-Control","forks_url":"https://api.github.com/repos/Automattic/Cron-Control/forks","keys_url":"https://api.github.com/repos/Automattic/Cron-Control/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/Cron-Control/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/Cron-Control/teams","hooks_url":"https://api.github.com/repos/Automattic/Cron-Control/hooks","issue_events_url":"https://api.github.com/repos/Automattic/Cron-Control/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/Cron-Control/events","assignees_url":"https://api.github.com/repos/Automattic/Cron-Control/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/Cron-Control/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/Cron-Control/tags","blobs_url":"https://api.github.com/repos/Automattic/Cron-Control/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/Cron-Control/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/Cron-Control/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/Cron-Control/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/Cron-Control/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/Cron-Control/languages","stargazers_url":"https://api.github.com/repos/Automattic/Cron-Control/stargazers","contributors_url":"https://api.github.com/repos/Automattic/Cron-Control/contributors","subscribers_url":"https://api.github.com/repos/Automattic/Cron-Control/subscribers","subscription_url":"https://api.github.com/repos/Automattic/Cron-Control/subscription","commits_url":"https://api.github.com/repos/Automattic/Cron-Control/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/Cron-Control/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/Cron-Control/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/Cron-Control/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/Cron-Control/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/Cron-Control/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/Cron-Control/merges","archive_url":"https://api.github.com/repos/Automattic/Cron-Control/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/Cron-Control/downloads","issues_url":"https://api.github.com/repos/Automattic/Cron-Control/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/Cron-Control/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/Cron-Control/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/Cron-Control/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/Cron-Control/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/Cron-Control/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/Cron-Control/deployments","created_at":"2016-11-05T03:15:35Z","updated_at":"2016-11-28T22:01:20Z","pushed_at":"2016-12-06T00:52:07Z","git_url":"git://github.com/Automattic/Cron-Control.git","ssh_url":"git@github.com:Automattic/Cron-Control.git","clone_url":"https://github.com/Automattic/Cron-Control.git","svn_url":"https://github.com/Automattic/Cron-Control","homepage":null,"size":206,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/Cron-Control/pulls/32"},"html":{"href":"https://github.com/Automattic/Cron-Control/pull/32"},"issue":{"href":"https://api.github.com/repos/Automattic/Cron-Control/issues/32"},"comments":{"href":"https://api.github.com/repos/Automattic/Cron-Control/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/Cron-Control/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/Cron-Control/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/Cron-Control/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/Cron-Control/statuses/749be4798f36974bdd0f5705550e2d3d34696089"}}}}
{"actor":{"display_login":"nickdaugherty"}}