Commit 2372f6de authored by Erick Hitter's avatar Erick Hitter
Browse files

PHPCS fixes

parent fac26d28
<?php <?php
/**
* Manage events via WP-CLI
*
* @package a8c_Cron_Control
*/
namespace Automattic\WP\Cron_Control\CLI; namespace Automattic\WP\Cron_Control\CLI;
...@@ -13,43 +18,45 @@ class Events extends \WP_CLI_Command { ...@@ -13,43 +18,45 @@ class Events extends \WP_CLI_Command {
* *
* @subcommand list * @subcommand list
* @synopsis [--status=<pending|completed>] [--page=<page>] [--limit=<limit>] [--format=<format>] * @synopsis [--status=<pending|completed>] [--page=<page>] [--limit=<limit>] [--format=<format>]
* @param array $args Array of positional arguments.
* @param array $assoc_args Array of flags.
*/ */
public function list_events( $args, $assoc_args ) { public function list_events( $args, $assoc_args ) {
$events = $this->get_events( $args, $assoc_args ); $events = $this->get_events( $args, $assoc_args );
// Prevent one from requesting a page that doesn't exist // Prevent one from requesting a page that doesn't exist.
// Shouldn't error when first page is requested, though, as that is handled below and is an odd behaviour otherwise // Shouldn't error when first page is requested, though, as that is handled below and is an odd behaviour otherwise.
if ( $events['page'] > $events['total_pages'] && $events['page'] > 1 ) { if ( $events['page'] > $events['total_pages'] && $events['page'] > 1 ) {
\WP_CLI::error( __( 'Invalid page requested', 'automattic-cron-control' ) ); \WP_CLI::error( __( 'Invalid page requested', 'automattic-cron-control' ) );
} }
// Output in the requested format // Output in the requested format.
if ( isset( $assoc_args['format'] ) && 'ids' === $assoc_args['format'] ) { if ( isset( $assoc_args['format'] ) && 'ids' === $assoc_args['format'] ) {
echo implode( ' ', wp_list_pluck( $events['items'], 'ID' ) ); echo implode( ' ', wp_list_pluck( $events['items'], 'ID' ) );
} else { } else {
// Lest someone think the `completed` record should be...complete // Lest someone think the `completed` record should be...complete.
if ( isset( $assoc_args['status'] ) && 'completed' === $assoc_args['status'] ) { if ( isset( $assoc_args['status'] ) && 'completed' === $assoc_args['status'] ) {
\WP_CLI::warning( __( 'Entries are purged automatically, so this cannot be relied upon as a record of past event execution.', 'automattic-cron-control' ) ); \WP_CLI::warning( __( 'Entries are purged automatically, so this cannot be relied upon as a record of past event execution.', 'automattic-cron-control' ) );
} }
// Not much to do // Not much to do.
if ( 0 === $events['total_items'] || empty( $events['items'] ) ) { if ( 0 === $events['total_items'] || empty( $events['items'] ) ) {
\WP_CLI::warning( __( 'No events to display', 'automattic-cron-control' ) ); \WP_CLI::warning( __( 'No events to display', 'automattic-cron-control' ) );
return; return;
} }
// Prepare events for display // Prepare events for display.
$events_for_display = $this->format_events( $events['items'] ); $events_for_display = $this->format_events( $events['items'] );
$total_events_to_display = count( $events_for_display ); $total_events_to_display = count( $events_for_display );
// Count, noting if showing fewer than all // Count, noting if showing fewer than all.
if ( $events['total_items'] <= $total_events_to_display ) { if ( $events['total_items'] <= $total_events_to_display ) {
\WP_CLI::log( sprintf( _n( 'Displaying one entry', 'Displaying all %s entries', $total_events_to_display, 'automattic-cron-control' ), number_format_i18n( $total_events_to_display ) ) ); \WP_CLI::log( sprintf( _n( 'Displaying %s entry', 'Displaying all %s entries', $total_events_to_display, 'automattic-cron-control' ), number_format_i18n( $total_events_to_display ) ) );
} else { } else {
\WP_CLI::log( sprintf( __( 'Displaying %1$s of %2$s entries, page %3$s of %4$s', 'automattic-cron-control' ), number_format_i18n( $total_events_to_display ), number_format_i18n( $events['total_items'] ), number_format_i18n( $events['page'] ), number_format_i18n( $events['total_pages'] ) ) ); \WP_CLI::log( sprintf( __( 'Displaying %1$s of %2$s entries, page %3$s of %4$s', 'automattic-cron-control' ), number_format_i18n( $total_events_to_display ), number_format_i18n( $events['total_items'] ), number_format_i18n( $events['page'] ), number_format_i18n( $events['total_pages'] ) ) );
} }
// And reformat // And reformat!
$format = 'table'; $format = 'table';
if ( isset( $assoc_args['format'] ) ) { if ( isset( $assoc_args['format'] ) ) {
$format = $assoc_args['format']; $format = $assoc_args['format'];
...@@ -75,21 +82,23 @@ class Events extends \WP_CLI_Command { ...@@ -75,21 +82,23 @@ class Events extends \WP_CLI_Command {
* *
* @subcommand delete * @subcommand delete
* @synopsis [--event_id=<event_id>] [--action=<action>] [--completed] * @synopsis [--event_id=<event_id>] [--action=<action>] [--completed]
* @param array $args Array of positional arguments.
* @param array $assoc_args Array of flags.
*/ */
public function delete_events( $args, $assoc_args ) { public function delete_events( $args, $assoc_args ) {
// Remove a specific event // Remove a specific event.
if ( isset( $assoc_args['event_id'] ) ) { if ( isset( $assoc_args['event_id'] ) ) {
$this->delete_event_by_id( $args, $assoc_args ); $this->delete_event_by_id( $args, $assoc_args );
return; return;
} }
// Remove all events with a given action // Remove all events with a given action.
if ( isset( $assoc_args['action'] ) ) { if ( isset( $assoc_args['action'] ) ) {
$this->delete_event_by_action( $args, $assoc_args ); $this->delete_event_by_action( $args, $assoc_args );
return; return;
} }
// Remove all completed events // Remove all completed events.
if ( isset( $assoc_args['completed'] ) ) { if ( isset( $assoc_args['completed'] ) ) {
$this->delete_completed_events( $args, $assoc_args ); $this->delete_completed_events( $args, $assoc_args );
return; return;
...@@ -103,14 +112,16 @@ class Events extends \WP_CLI_Command { ...@@ -103,14 +112,16 @@ class Events extends \WP_CLI_Command {
* *
* @subcommand run * @subcommand run
* @synopsis <event_id> * @synopsis <event_id>
* @param array $args Array of positional arguments.
* @param array $assoc_args Array of flags.
*/ */
public function run_event( $args, $assoc_args ) { public function run_event( $args, $assoc_args ) {
// Validate ID // Validate ID.
if ( ! is_numeric( $args[0] ) ) { if ( ! is_numeric( $args[0] ) ) {
\WP_CLI::error( __( 'Specify the ID of an event to run', 'automattic-cron-control' ) ); \WP_CLI::error( __( 'Specify the ID of an event to run', 'automattic-cron-control' ) );
} }
// Retrieve information needed to execute event // Retrieve information needed to execute event.
$event = \Automattic\WP\Cron_Control\get_event_by_id( $args[0] ); $event = \Automattic\WP\Cron_Control\get_event_by_id( $args[0] );
if ( ! is_object( $event ) ) { if ( ! is_object( $event ) ) {
...@@ -127,13 +138,13 @@ class Events extends \WP_CLI_Command { ...@@ -127,13 +138,13 @@ class Events extends \WP_CLI_Command {
\WP_CLI::confirm( sprintf( __( 'Run this event?', 'automattic-cron-control' ) ) ); \WP_CLI::confirm( sprintf( __( 'Run this event?', 'automattic-cron-control' ) ) );
// Environment preparation // Environment preparation.
\Automattic\WP\Cron_Control\set_doing_cron(); \Automattic\WP\Cron_Control\set_doing_cron();
// Run the event // Run the event!
$run = \Automattic\WP\Cron_Control\run_event( $event->timestamp, $event->action_hashed, $event->instance, true ); $run = \Automattic\WP\Cron_Control\run_event( $event->timestamp, $event->action_hashed, $event->instance, true );
// Output based on run attempt // Output based on run attempt.
if ( is_array( $run ) ) { if ( is_array( $run ) ) {
\WP_CLI::success( $run['message'] ); \WP_CLI::success( $run['message'] );
} elseif ( is_wp_error( $run ) ) { } elseif ( is_wp_error( $run ) ) {
...@@ -145,15 +156,19 @@ class Events extends \WP_CLI_Command { ...@@ -145,15 +156,19 @@ class Events extends \WP_CLI_Command {
/** /**
* Retrieve list of events, and related data, for a given request * Retrieve list of events, and related data, for a given request
*
* @param array $args Array of positional arguments.
* @param array $assoc_args Array of flags.
* @return array
*/ */
private function get_events( $args, $assoc_args ) { private function get_events( $args, $assoc_args ) {
// Accept a status argument, with a default // Accept a status argument, with a default.
$status = 'pending'; $status = 'pending';
if ( isset( $assoc_args['status'] ) ) { if ( isset( $assoc_args['status'] ) ) {
$status = $assoc_args['status']; $status = $assoc_args['status'];
} }
// Convert to status used by Event Store // Convert to status used by Event Store.
$event_status = null; $event_status = null;
switch ( $status ) { switch ( $status ) {
case 'pending' : case 'pending' :
...@@ -175,13 +190,13 @@ class Events extends \WP_CLI_Command { ...@@ -175,13 +190,13 @@ class Events extends \WP_CLI_Command {
unset( $status ); unset( $status );
// Total to show // Total to show.
$limit = 25; $limit = 25;
if ( isset( $assoc_args['limit'] ) && is_numeric( $assoc_args['limit'] ) ) { if ( isset( $assoc_args['limit'] ) && is_numeric( $assoc_args['limit'] ) ) {
$limit = max( 1, min( absint( $assoc_args['limit'] ), 500 ) ); $limit = max( 1, min( absint( $assoc_args['limit'] ), 500 ) );
} }
// Pagination // Pagination.
$page = 1; $page = 1;
if ( isset( $assoc_args['page'] ) && is_numeric( $assoc_args['page'] ) ) { if ( isset( $assoc_args['page'] ) && is_numeric( $assoc_args['page'] ) ) {
$page = absint( $assoc_args['page'] ); $page = absint( $assoc_args['page'] );
...@@ -189,7 +204,7 @@ class Events extends \WP_CLI_Command { ...@@ -189,7 +204,7 @@ class Events extends \WP_CLI_Command {
$offset = absint( ( $page - 1 ) * $limit ); $offset = absint( ( $page - 1 ) * $limit );
// Query // Query!
$items = \Automattic\WP\Cron_Control\get_events( array( $items = \Automattic\WP\Cron_Control\get_events( array(
'status' => $event_status, 'status' => $event_status,
'quantity' => $limit, 'quantity' => $limit,
...@@ -197,12 +212,12 @@ class Events extends \WP_CLI_Command { ...@@ -197,12 +212,12 @@ class Events extends \WP_CLI_Command {
'force_sort' => true, 'force_sort' => true,
) ); ) );
// Bail if we don't get results // Bail if we don't get results!
if ( ! is_array( $items ) ) { if ( ! is_array( $items ) ) {
\WP_CLI::error( __( 'Problem retrieving events', 'automattic-cron-control' ) ); \WP_CLI::error( __( 'Problem retrieving events', 'automattic-cron-control' ) );
} }
// Include totals for pagination etc // Include totals for pagination etc.
$total_items = \Automattic\WP\Cron_Control\count_events_by_status( $event_status ); $total_items = \Automattic\WP\Cron_Control\count_events_by_status( $event_status );
$total_pages = ceil( $total_items / $limit ); $total_pages = ceil( $total_items / $limit );
...@@ -211,11 +226,14 @@ class Events extends \WP_CLI_Command { ...@@ -211,11 +226,14 @@ class Events extends \WP_CLI_Command {
/** /**
* Format event data into something human-readable * Format event data into something human-readable
*
* @param array $events Array of events to reformat.
* @return array
*/ */
private function format_events( $events ) { private function format_events( $events ) {
$formatted_events = array(); $formatted_events = array();
// Reformat events // Reformat events.
foreach ( $events as $event ) { foreach ( $events as $event ) {
$row = array( $row = array(
'ID' => $event->ID, 'ID' => $event->ID,
...@@ -230,7 +248,7 @@ class Events extends \WP_CLI_Command { ...@@ -230,7 +248,7 @@ class Events extends \WP_CLI_Command {
'event_args' => '', 'event_args' => '',
); );
if ( $event->status === \Automattic\WP\Cron_Control\Events_Store::STATUS_PENDING ) { if ( \Automattic\WP\Cron_Control\Events_Store::STATUS_PENDING === $event->status ) {
$row['next_run_relative'] = $this->calculate_interval( $event->timestamp - time() ); $row['next_run_relative'] = $this->calculate_interval( $event->timestamp - time() );
} }
...@@ -254,7 +272,7 @@ class Events extends \WP_CLI_Command { ...@@ -254,7 +272,7 @@ class Events extends \WP_CLI_Command {
$formatted_events[] = $row; $formatted_events[] = $row;
} }
// Sort results // Sort results.
if ( ! empty( $formatted_events ) ) { if ( ! empty( $formatted_events ) ) {
usort( $formatted_events, array( $this, 'sort_events' ) ); usort( $formatted_events, array( $this, 'sort_events' ) );
} }
...@@ -264,9 +282,13 @@ class Events extends \WP_CLI_Command { ...@@ -264,9 +282,13 @@ class Events extends \WP_CLI_Command {
/** /**
* Sort events by timestamp, then action name * Sort events by timestamp, then action name
*
* @param array $first First event to compare.
* @param array $second Second event to compare.
* @return int
*/ */
private function sort_events( $first, $second ) { private function sort_events( $first, $second ) {
// Timestamp is usually sufficient // Timestamp is usually sufficient.
if ( isset( $first['next_run_gmt'] ) ) { if ( isset( $first['next_run_gmt'] ) ) {
$first_timestamp = strtotime( $first['next_run_gmt'] ); $first_timestamp = strtotime( $first['next_run_gmt'] );
$second_timestamp = strtotime( $second['next_run_gmt'] ); $second_timestamp = strtotime( $second['next_run_gmt'] );
...@@ -281,7 +303,7 @@ class Events extends \WP_CLI_Command { ...@@ -281,7 +303,7 @@ class Events extends \WP_CLI_Command {
return $first_timestamp - $second_timestamp; return $first_timestamp - $second_timestamp;
} }
// If timestamps are equal, consider action // If timestamps are equal, consider action.
return strnatcasecmp( $first['action'], $second['action'] ); return strnatcasecmp( $first['action'], $second['action'] );
} }
...@@ -292,8 +314,8 @@ class Events extends \WP_CLI_Command { ...@@ -292,8 +314,8 @@ class Events extends \WP_CLI_Command {
* *
* Borrowed from WP-CLI * Borrowed from WP-CLI
* *
* @param int $since An interval of time in seconds * @param int $since An interval of time in seconds.
* @return string The interval in human readable format * @return string
*/ */
private function calculate_interval( $since ) { private function calculate_interval( $since ) {
if ( $since <= 0 ) { if ( $since <= 0 ) {
...@@ -302,7 +324,7 @@ class Events extends \WP_CLI_Command { ...@@ -302,7 +324,7 @@ class Events extends \WP_CLI_Command {
$since = absint( $since ); $since = absint( $since );
// array of time period chunks // array of time period chunks.
$chunks = array( $chunks = array(
array( 60 * 60 * 24 * 365 , \_n_noop( '%s year', '%s years' ) ), array( 60 * 60 * 24 * 365 , \_n_noop( '%s year', '%s years' ) ),
array( 60 * 60 * 24 * 30 , \_n_noop( '%s month', '%s months' ) ), array( 60 * 60 * 24 * 30 , \_n_noop( '%s month', '%s months' ) ),
...@@ -310,36 +332,38 @@ class Events extends \WP_CLI_Command { ...@@ -310,36 +332,38 @@ class Events extends \WP_CLI_Command {
array( 60 * 60 * 24 , \_n_noop( '%s day', '%s days' ) ), array( 60 * 60 * 24 , \_n_noop( '%s day', '%s days' ) ),
array( 60 * 60 , \_n_noop( '%s hour', '%s hours' ) ), array( 60 * 60 , \_n_noop( '%s hour', '%s hours' ) ),
array( 60 , \_n_noop( '%s minute', '%s minutes' ) ), array( 60 , \_n_noop( '%s minute', '%s minutes' ) ),
array( 1 , \_n_noop( '%s second', '%s seconds' ) ), array( 01 , \_n_noop( '%s second', '%s seconds' ) ),
); );
// we only want to output two chunks of time here, eg: /**
// x years, xx months * We only want to output two chunks of time here, eg:
// x days, xx hours * x years, xx months
// so there's only two bits of calculation below: * x days, xx hours
* so there's only two bits of calculation below:
*/
// step one: the first chunk // step one: the first chunk.
for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) { for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) {
$seconds = $chunks[$i][0]; $seconds = $chunks[ $i ][0];
$name = $chunks[$i][1]; $name = $chunks[ $i ][1];
// finding the biggest chunk (if the chunk fits, break) // finding the biggest chunk (if the chunk fits, break).
if ( ( $count = floor( $since / $seconds ) ) != 0 ){ if ( ( $count = floor( $since / $seconds ) ) != 0 ) {
break; break;
} }
} }
// set output var // set output var.
$output = sprintf( \_n( $name[0], $name[1], $count ), $count ); $output = sprintf( \_n( $name[0], $name[1], $count ), $count ); // @codingStandardsIgnoreLine
// step two: the second chunk // step two: the second chunk.
if ( $i + 1 < $j ) { if ( $i + 1 < $j ) {
$seconds2 = $chunks[$i + 1][0]; $seconds2 = $chunks[ $i + 1 ][0];
$name2 = $chunks[$i + 1][1]; $name2 = $chunks[ $i + 1 ][1];
if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) { if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
// add to output var // add to output var.
$output .= ' ' . sprintf( \_n( $name2[0], $name2[1], $count2 ), $count2 ); $output .= ' ' . sprintf( \_n( $name2[0], $name2[1], $count2 ), $count2 ); // @codingStandardsIgnoreLine
} }
} }
...@@ -348,22 +372,25 @@ class Events extends \WP_CLI_Command { ...@@ -348,22 +372,25 @@ class Events extends \WP_CLI_Command {
/** /**
* Delete an event by ID * Delete an event by ID
*
* @param array $args Array of positional arguments.
* @param array $assoc_args Array of flags.
*/ */
private function delete_event_by_id( $args, $assoc_args ) { private function delete_event_by_id( $args, $assoc_args ) {
$jid = absint( $assoc_args['event_id'] ); $jid = absint( $assoc_args['event_id'] );
// Validate ID // Validate ID.
if ( ! $jid ) { if ( ! $jid ) {
\WP_CLI::error( __( 'Invalid event ID', 'automattic-cron-control' ) ); \WP_CLI::error( __( 'Invalid event ID', 'automattic-cron-control' ) );
} }
\WP_CLI::log( __( 'Locating event...', 'automattic-cron-control' ) . "\n" ); \WP_CLI::log( __( 'Locating event...', 'automattic-cron-control' ) . "\n" );
// Look up full event object // Look up full event object.
$event = \Automattic\WP\Cron_Control\get_event_by_id( $jid ); $event = \Automattic\WP\Cron_Control\get_event_by_id( $jid );
if ( is_object( $event ) ) { if ( is_object( $event ) ) {
// Warning about Internal Events // Warning about Internal Events.
if ( \Automattic\WP\Cron_Control\is_internal_event( $event->action ) ) { if ( \Automattic\WP\Cron_Control\is_internal_event( $event->action ) ) {
\WP_CLI::warning( __( 'This is an event created by the Cron Control plugin. It will recreated automatically.', 'automattic-cron-control' ) ); \WP_CLI::warning( __( 'This is an event created by the Cron Control plugin. It will recreated automatically.', 'automattic-cron-control' ) );
} }
...@@ -374,7 +401,7 @@ class Events extends \WP_CLI_Command { ...@@ -374,7 +401,7 @@ class Events extends \WP_CLI_Command {
\WP_CLI::log( '' ); \WP_CLI::log( '' );
\WP_CLI::confirm( sprintf( __( 'Are you sure you want to delete this event?', 'automattic-cron-control' ) ) ); \WP_CLI::confirm( sprintf( __( 'Are you sure you want to delete this event?', 'automattic-cron-control' ) ) );
// Try to delete the item and provide some relevant output // Try to delete the item and provide some relevant output.
\Automattic\WP\Cron_Control\_suspend_event_creation(); \Automattic\WP\Cron_Control\_suspend_event_creation();
$deleted = \Automattic\WP\Cron_Control\delete_event_by_id( $event->ID, true ); $deleted = \Automattic\WP\Cron_Control\delete_event_by_id( $event->ID, true );
\Automattic\WP\Cron_Control\_resume_event_creation(); \Automattic\WP\Cron_Control\_resume_event_creation();
...@@ -393,42 +420,45 @@ class Events extends \WP_CLI_Command { ...@@ -393,42 +420,45 @@ class Events extends \WP_CLI_Command {
/** /**
* Delete all events of the same action * Delete all events of the same action
*
* @param array $args Array of positional arguments.
* @param array $assoc_args Array of flags.
*/ */
private function delete_event_by_action( $args, $assoc_args ) { private function delete_event_by_action( $args, $assoc_args ) {
$action = $assoc_args['action']; $action = $assoc_args['action'];
// Validate entry // Validate entry.
if ( empty( $action ) ) { if ( empty( $action ) ) {
\WP_CLI::error( __( 'Invalid action', 'automattic-cron-control' ) ); \WP_CLI::error( __( 'Invalid action', 'automattic-cron-control' ) );
} }
// Warning about Internal Events // Warning about Internal Events.
if ( \Automattic\WP\Cron_Control\is_internal_event( $action ) ) { if ( \Automattic\WP\Cron_Control\is_internal_event( $action ) ) {
\WP_CLI::warning( __( 'This is an event created by the Cron Control plugin. It will recreated automatically.', 'automattic-cron-control' ) ); \WP_CLI::warning( __( 'This is an event created by the Cron Control plugin. It will recreated automatically.', 'automattic-cron-control' ) );
} }
// Set defaults needed to gather all events // Set defaults needed to gather all events.
$assoc_args['page'] = 1; $assoc_args['page'] = 1;
$assoc_args['limit'] = 50; $assoc_args['limit'] = 50;
// Gather events // Gather events.
\WP_CLI::log( __( 'Gathering events...', 'automattic-cron-control' ) ); \WP_CLI::log( __( 'Gathering events...', 'automattic-cron-control' ) );
$events_to_delete = array(); $events_to_delete = array();
$events = $this->get_events( $args, $assoc_args ); $events = $this->get_events( $args, $assoc_args );
\WP_CLI::log( sprintf( _n( 'Found one event to check', 'Found %s events to check', $events['total_items'], 'automattic-cron-control' ), number_format_i18n( $events['total_items'] ) ) ); \WP_CLI::log( sprintf( _n( 'Found %s event to check', 'Found %s events to check', $events['total_items'], 'automattic-cron-control' ), number_format_i18n( $events['total_items'] ) ) );
$search_progress = \WP_CLI\Utils\make_progress_bar( sprintf( __( 'Searching events for those with the action `%s`', 'automattic-cron-control' ), $action ), $events['total_items'] ); $search_progress = \WP_CLI\Utils\make_progress_bar( sprintf( __( 'Searching events for those with the action `%s`', 'automattic-cron-control' ), $action ), $events['total_items'] );
// Loop and pull out events to be deleted // Loop and pull out events to be deleted.
do { do {
if ( ! is_array( $events ) || empty( $events['items'] ) ) { if ( ! is_array( $events ) || empty( $events['items'] ) ) {
break; break;
} }
// Check events for those that should be deleted // Check events for those that should be deleted.
foreach ( $events['items'] as $single_event ) { foreach ( $events['items'] as $single_event ) {
if ( $single_event->action === $action ) { if ( $single_event->action === $action ) {
$events_to_delete[] = (array) $single_event; $events_to_delete[] = (array) $single_event;
...@@ -437,7 +467,7 @@ class Events extends \WP_CLI_Command { ...@@ -437,7 +467,7 @@ class Events extends \WP_CLI_Command {
$search_progress->tick(); $search_progress->tick();
} }
// Proceed to next batch // Proceed to next batch.
$assoc_args['page']++; $assoc_args['page']++;
if ( $assoc_args['page'] > $events['total_pages'] ) { if ( $assoc_args['page'] > $events['total_pages'] ) {
...@@ -445,29 +475,28 @@ class Events extends \WP_CLI_Command { ...@@ -445,29 +475,28 @@ class Events extends \WP_CLI_Command {
} }
$events = $this->get_events( $args, $assoc_args ); $events = $this->get_events( $args, $assoc_args );
} while( $events['page'] <= $events['total_pages'] ); } while ( $events['page'] <= $events['total_pages'] );