Correzioni per esecuzione aggiornamenti

This commit is contained in:
Dasc3er 2021-07-07 11:27:46 +02:00 committed by Thomas Zilio
parent 011b33baf3
commit 735d3b2bf9
3 changed files with 72 additions and 85 deletions

View File

@ -613,7 +613,7 @@ function apriTab(link) {
function ajaxError(xhr, error, thrown) {
swal({
title: globals.translations.errorTitle,
html: globals.translations.errorMessage + (xhr.responseJSON ? ".<br><i>" + xhr.responseJSON.exception[0].message + "</i>" : ''),
html: globals.translations.errorMessage + (xhr.responseJSON ? ".<br><i>" + xhr.responseJSON.exception + ": " + xhr.responseJSON.message + "</i>" : ""),
type: "error",
});
}

View File

@ -27,12 +27,6 @@ use Illuminate\Support\Facades\Schema;
*/
class Database
{
/** @var \Illuminate\Database\Capsule\Manager Gestore di connessione Laravel */
protected $capsule;
/** @var string Nome del database */
protected $database_name;
/** @var bool Stato di connessione del database */
protected $is_connected;
/** @var bool Stato di installazione del database */
@ -122,7 +116,7 @@ class Database
*/
public function getDatabaseName()
{
return $this->database_name;
return DB::connection()->getDatabaseName();
}
/**

View File

@ -241,11 +241,10 @@ class Update
if (!self::isUpdateCompleted()) {
$update = self::getCurrentUpdate();
$file = base_dir().'/'.$update['directory'].$update['filename'];
$file = slashes(base_dir().substr($update['directory'], 1).$update['filename']);
$database = database();
try {
// Esecuzione delle query
if (!empty($update['sql']) && (!empty($update['done']) || is_null($update['done'])) && file_exists($file.'.sql')) {
$queries = readSQLFile($file.'.sql', ';');
@ -259,7 +258,7 @@ class Update
try {
$database->query($queries[$i]);
} catch (\Exception $e) {
throw new PDOException(tr('Aggiornamento fallito').': '.$queries[$i]);
throw new PDOException($queries[$i]);
}
$database->query('UPDATE `updates` SET `done` = :done WHERE id = :id', [
@ -321,14 +320,6 @@ class Update
// Normalizzazione di charset e collation
self::normalizeDatabase($database->getDatabaseName());
return true;
} catch (\Exception $e) {
$logger = logger();
$logger->addRecord(\Monolog\Logger::EMERGENCY, $e->getMessage());
}
return false;
}
return true;
@ -437,8 +428,8 @@ class Update
// Inserimento degli aggiornamenti individuati
foreach ($results as $result) {
// Individuazione di script e sql
$sql = file_exists($result['path'].'.sql') ? 1 : 0;
$script = file_exists($result['path'].'.php') ? 1 : 0;
$sql = file_exists(base_dir().$result['path'].'.sql') ? 1 : 0;
$script = file_exists(base_dir().$result['path'].'.php') ? 1 : 0;
// Reimpostazione degli stati per gli aggiornamenti precedentemente presenti
$pos = array_search($result['path'], $versions);
@ -574,6 +565,8 @@ class Update
*/
protected static function normalizeDatabase($database_name)
{
return;
set_time_limit(0);
ignore_user_abort(true);