fix: [updateProgress] Display errors in between updates

Return empty progress when the current progress can't be fetched
pull/5526/head
mokaddem 2020-01-20 13:24:51 +01:00
parent 6dc79425dd
commit 92ebdfaba8
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 11 additions and 9 deletions

View File

@ -286,8 +286,7 @@ class AppModel extends Model
public function updateDatabase($command)
{
$this->Log = ClassRegistry::init('Log');
$this->__resetUpdateProgress();
$liveOff = false;
$exitOnError = false;
if (isset($this->advanced_updates_description[$command])) {
@ -1318,7 +1317,6 @@ class AppModel extends Model
break;
case 44:
$sqlArray[] = "ALTER TABLE object_template_elements CHANGE `disable_correlation` `disable_correlation` tinyint(1);";
break;
case 45:
$sqlArray[] = "ALTER TABLE `events` ADD `sighting_timestamp` int(11) NOT NULL DEFAULT 0 AFTER `publish_timestamp`;";
@ -1846,6 +1844,7 @@ class AppModel extends Model
return true;
}
$this->changeLockState(time());
$this->__resetUpdateProgress();
$update_done = 0;
foreach ($updates as $update => $temp) {
@ -1926,9 +1925,9 @@ class AppModel extends Model
$this->__saveUpdateProgress($updateProgress);
}
private function __resetUpdateProgress()
private function __getEmptyUpdateMessage()
{
$updateProgress = array(
return array(
'commands' => array(),
'results' => array(),
'time' => array('started' => array(), 'elapsed' => array()),
@ -1937,6 +1936,11 @@ class AppModel extends Model
'failed_num' => array(),
'toward_db_version' => ''
);
}
private function __resetUpdateProgress()
{
$updateProgress = $this->__getEmptyUpdateMessage();
$this->__saveUpdateProgress($updateProgress);
}
@ -1966,9 +1970,7 @@ class AppModel extends Model
if ($updateProgress !== false) {
$updateProgress = json_decode($updateProgress, true);
} else {
$this->__resetUpdateProgress();
$updateProgress = $this->AdminSetting->getSetting('update_progress');
$updateProgress = json_decode($updateProgress, true);
$updateProgress = $this->__getEmptyUpdateMessage();
}
foreach($updateProgress as $setting => $value) {
if (!is_array($value)) {

View File

@ -5,7 +5,7 @@ $towardDbVersion = $updateProgress['toward_db_version'];
$updateLocked = $updateProgress['update_locked'];
$lockRemainingTime = $updateProgress['lock_remaining_time'];
$updateFailNumberReached = $updateProgress['update_fail_number_reached'];
if ($updateProgress['total'] !== 0 ) {
if (!empty($updateProgress['total'])) {
$percentageFail = floor(count($updateProgress['failed_num']) / $updateProgress['total']*100);
$percentage = floor(($updateProgress['current']) / $updateProgress['total']*100);
} else {