Skip to content

Commit

Permalink
get_sync_status does not properly account for unexpected states. (#14…
Browse files Browse the repository at this point in the history
…684)

Handle _get_cron_array returning false
Handle full-sync module returning false
  • Loading branch information
mdbitz authored and jeherve committed Feb 14, 2020
1 parent 26ab953 commit 070a46e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/class-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,10 @@ public static function get_sync_status( $fields = null ) {

$sync_module = Modules::get_module( 'full-sync' );
$queue = self::$sender->get_sync_queue();
$cron_timestamps = array_keys( _get_cron_array() );
$next_cron = $cron_timestamps[0] - time();

// _get_cron_array can be false
$cron_timestamps = ( _get_cron_array() ) ? array_keys( _get_cron_array() ) : array();
$next_cron = ( ! empty( $cron_timestamps ) ) ? $cron_timestamps[0] - time() : '';

$checksums = array();

Expand Down Expand Up @@ -767,7 +769,8 @@ public static function get_sync_status( $fields = null ) {
)
);

if ( false === strpos( get_class( $sync_module ), 'Full_Sync_Immediately' ) ) {
// Verify $sync_module is not false
if ( ( $sync_module ) && false === strpos( get_class( $sync_module ), 'Full_Sync_Immediately' ) ) {
$result['full_queue_size'] = $full_queue->size();
$result['full_queue_lag'] = $full_queue->lag();
}
Expand Down

0 comments on commit 070a46e

Please sign in to comment.