Apply suggestions from code review
Co-authored-by: Hypolite Petovan <hypolite@mrpetovan.com>
This commit is contained in:
parent
965caf98a5
commit
925c30280c
|
@ -104,9 +104,7 @@ class DBKeyValueStorage extends AbstractKeyValueStorage
|
|||
public function offsetUnset($offset)
|
||||
{
|
||||
try {
|
||||
$return = $this->database->delete(self::DB_KEY_VALUE_TABLE, ['k' => $offset]);
|
||||
|
||||
if (!$return) {
|
||||
if (!$this->database->delete(self::DB_KEY_VALUE_TABLE, ['k' => $offset])) {
|
||||
throw new \Exception(sprintf('database deletion failed: %s', $this->database->errorMessage()));
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
|
|
|
@ -53,7 +53,7 @@ class DBStructure
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('The version number must be numeric');
|
||||
}
|
||||
|
||||
DI::keyValue()->set( 'build', $version);
|
||||
DI::keyValue()->set('build', $version);
|
||||
echo DI::l10n()->t('The database version had been set to %s.', $version);
|
||||
}
|
||||
|
||||
|
@ -176,14 +176,14 @@ class DBStructure
|
|||
public static function performUpdate(bool $enable_maintenance_mode = true, bool $verbose = false): string
|
||||
{
|
||||
if ($enable_maintenance_mode) {
|
||||
DI::keyValue()->set( 'maintenance', 1);
|
||||
DI::keyValue()->set('maintenance', 1);
|
||||
}
|
||||
|
||||
$status = self::update($verbose, true);
|
||||
|
||||
if ($enable_maintenance_mode) {
|
||||
DI::keyValue()->set( 'maintenance', 0);
|
||||
DI::keyValue()->set( 'maintenance_reason', '');
|
||||
DI::keyValue()->set('maintenance', 0);
|
||||
DI::keyValue()->set('maintenance_reason', '');
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
@ -213,7 +213,7 @@ class DBStructure
|
|||
*/
|
||||
private static function update(bool $verbose, bool $action, bool $install = false, array $tables = null, array $definition = null): string
|
||||
{
|
||||
$in_maintenance_mode = DI::keyValue()->get('system', 'maintenance');
|
||||
$in_maintenance_mode = DI::keyValue()->get('system', 'maintenance');
|
||||
|
||||
if ($action && !$install && self::isUpdating()) {
|
||||
return DI::l10n()->t('Another database update is currently running.');
|
||||
|
@ -494,9 +494,9 @@ class DBStructure
|
|||
|
||||
if ($action && !$install) {
|
||||
if ($errors) {
|
||||
DI::config()->set('system', 'dbupdate', self::UPDATE_FAILED);
|
||||
DI::config()->set('system', 'dbupdate', self::UPDATE_FAILED);
|
||||
} else {
|
||||
DI::config()->set( 'system', 'dbupdate', self::UPDATE_SUCCESSFUL);
|
||||
DI::config()->set('system', 'dbupdate', self::UPDATE_SUCCESSFUL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class Summary extends BaseAdmin
|
|||
$warningtext[] = DI::l10n()->t('The last update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear. (Some of the errors are possibly inside the logfile.)');
|
||||
}
|
||||
|
||||
$last_worker_call = DI::keyValue()->get('last_worker_execution') ?? false;
|
||||
$last_worker_call = DI::keyValue()->get('last_worker_execution');
|
||||
if (!$last_worker_call) {
|
||||
$warningtext[] = DI::l10n()->t('The worker was never executed. Please check your database structure!');
|
||||
} elseif ((strtotime(DateTimeFormat::utcNow()) - strtotime($last_worker_call)) > 60 * 60) {
|
||||
|
|
Loading…
Reference in a new issue