diff --git a/inc/fw-update.php b/inc/fw-update.php index d0482d1de..51de8a6e5 100644 --- a/inc/fw-update.php +++ b/inc/fw-update.php @@ -118,6 +118,7 @@ function spbc_security_firewall_update__worker($checker_work = null) Request::equal('updating_id', '') || ! Request::equal('updating_id', $spbc->fw_stats['updating_id']) ) { + spbc_security_firewall_update_log('FW UPDATE WORKER: WRONG_UPDATE_ID'); return array( 'error' => 'FW UPDATE WORKER: WRONG_UPDATE_ID' ); } } @@ -128,6 +129,7 @@ function spbc_security_firewall_update__worker($checker_work = null) if ( $spbc->fw_stats['calls'] > 600 ) { $spbc->error_add('firewall_update', 'WORKER_CALL_LIMIT_EXCEEDED'); $spbc->save('errors'); + spbc_security_firewall_update_log('WORKER_CALL_LIMIT_EXCEEDED'); return array( 'error' => 'WORKER_CALL_LIMIT_EXCEEDED' ); } @@ -138,8 +140,12 @@ function spbc_security_firewall_update__worker($checker_work = null) return true; } + spbc_security_firewall_update_log('Queue stage started ' . var_export($queue->getQueue(), true)); + $result = $queue->executeStage(); + spbc_security_firewall_update_log('Current stage result ' . var_export($result, true)); + if ( $result === null ) { // The stage is in progress, will try to wait up to 5 seconds to its complete for ( $i = 0; $i < 5; $i++ ) { diff --git a/lib/CleantalkSP/Common/Queue.php b/lib/CleantalkSP/Common/Queue.php index 240478225..18b242bf4 100644 --- a/lib/CleantalkSP/Common/Queue.php +++ b/lib/CleantalkSP/Common/Queue.php @@ -129,15 +129,22 @@ public function executeStage() if ($stage_to_execute) { if (is_callable($stage_to_execute['name'])) { + spbc_security_firewall_update_log('Is callable:' . var_export($stage_to_execute['name'], true)); + ++$stage_to_execute['tries']; if (! empty($stage_to_execute['args'])) { $result = $stage_to_execute['name']($stage_to_execute['args']); + spbc_security_firewall_update_log('Executed stage: ' . var_export($stage_to_execute['name'], true) . ' with args ' . var_export($stage_to_execute['args'], true)); } else { $result = $stage_to_execute['name'](); + spbc_security_firewall_update_log('Executed stage: ' . var_export($stage_to_execute['name'], true) . ' with no args'); } + spbc_security_firewall_update_log('Stage result ' . var_export($result, true)); + if (isset($result['error'])) { + spbc_security_firewall_update_log('Stage error ' . var_export($result['error'], true)); $stage_to_execute['status'] = 'NULL'; $stage_to_execute['error'][] = $result['error']; if (isset($result['update_args']['args'])) { @@ -148,11 +155,12 @@ public function executeStage() if ($stage_to_execute['tries'] >= $accepted_tries) { $stage_to_execute['status'] = 'FINISHED'; $this->saveQueue(); - return $result; } - return \CleantalkSP\SpbctWP\RemoteCalls::performToHost( + spbc_security_firewall_update_log('Stage has errors, proceed to RC ' . var_export($this->rc_name, true)); + + $rc_result = \CleantalkSP\SpbctWP\RemoteCalls::performToHost( $this->rc_name, array( 'updating_id' => $spbc->fw_stats['updating_id'], @@ -160,6 +168,10 @@ public function executeStage() ), array('async') ); + + spbc_security_firewall_update_log('Stage RC result' . var_export($rc_result, true)); + + return $rc_result; } if (isset($result['next_stage'])) {