minor improvement (err. messages)

This commit is contained in:
fbsanchez 2021-03-25 14:25:09 +01:00
parent fdc4133eaa
commit 7b7ef3a757
2 changed files with 15 additions and 7 deletions

View File

@ -1496,6 +1496,7 @@ function db_run_sql_file($location)
// Undo results // Undo results
} }
$config['db_run_sql_file_error'] = $mysqli->error;
return false; return false;
} }
} }

View File

@ -521,7 +521,10 @@ final class DBMaintainer
$target_mr = $matches[1]; $target_mr = $matches[1];
} }
$active_mr = (int) Config::get('MR', null); // Active database MR version.
$active_mr = (int) Config::get('MR', 0);
// Historical database MR version.
$last_mr_curr = (int) $this->getValue( $last_mr_curr = (int) $this->getValue(
'tconfig', 'tconfig',
'value', 'value',
@ -575,20 +578,21 @@ final class DBMaintainer
$err .= $last_mr_curr.': '; $err .= $last_mr_curr.': ';
$this->lastError = $err.$this->lastError; $this->lastError = $err.$this->lastError;
return false; return false;
} } else {
} // Update MR value.
}
if ($last_mr_curr === $active_mr) {
$this->setConfigToken('MR', $last_mr_curr); $this->setConfigToken('MR', $last_mr_curr);
}
return true; }
} }
if ($last_mr_curr !== $active_mr) {
$this->lastError = 'Unknown database schema version, check MR in both active and historical database'; $this->lastError = 'Unknown database schema version, check MR in both active and historical database';
return false; return false;
} }
return true;
}
/** /**
* Process database checks perform required actions. * Process database checks perform required actions.
@ -711,6 +715,9 @@ final class DBMaintainer
// MR are loaded in transactions. // MR are loaded in transactions.
include_once $config['homedir'].'/include/db/mysql.php'; include_once $config['homedir'].'/include/db/mysql.php';
$return = db_run_sql_file($path); $return = db_run_sql_file($path);
if ($return === false) {
$this->lastError = $config['db_run_sql_file_error'];
}
// Revert global variable. // Revert global variable.
$config['dbhost'] = $backup_dbhost; $config['dbhost'] = $backup_dbhost;