]> git.mxchange.org Git - friendica.git/commitdiff
Apply suggestions from code review
authorPhilipp <admin+Github@philipp.info>
Thu, 29 Dec 2022 21:12:02 +0000 (22:12 +0100)
committerGitHub <noreply@github.com>
Thu, 29 Dec 2022 21:12:02 +0000 (22:12 +0100)
Co-authored-by: Hypolite Petovan <hypolite@mrpetovan.com>
src/Core/KeyValueStorage/Type/DBKeyValueStorage.php
src/Database/DBStructure.php
src/Module/Admin/Summary.php

index 1d7040c0465b4616dd213a15a4ed09bc83849b6a..60e6087e28371e582805850ca1c17559cc7b311b 100644 (file)
@@ -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) {
index 83e238394ec20b1a59d18936b6a1b900bb42292c..734046afbaee4e216fc3788e5aa43a0357f837fd 100644 (file)
@@ -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);
                        }
                }
 
index 42098c95cd299ddfa7306861d28ec3f287300372..46f9d440bd815ca16a45e2b9ff408ced44583d42 100644 (file)
@@ -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) {