commit 80988222e8758b28ae80822dc84b1d8cfa2e3708
parent c04458e3c96a7969284bf4b10e90c9a5ab0ed06f
Author: Jan Dankert <develop@jandankert.de>
Date: Sat, 6 Nov 2021 01:35:17 +0100
Cleanup
Diffstat:
2 files changed, 14 insertions(+), 28 deletions(-)
diff --git a/modules/cms/status/Status.class.php b/modules/cms/status/Status.class.php
@@ -66,14 +66,18 @@ class Status
$db = new Database($dbConfig->subset('read')->getConfig() + $dbConfig->getConfig());
$update = new Update();
- $version = $update->getDbVersion( $db );
- $db->disconnect();
+ if ( $update->isUpdateRequired( $db ) )
+ $dbState = [
+ 'state' => 'UP',
+ ];
+ else
+ $dbState = [
+ 'state' => 'DOWN',
+ 'message' => 'NEEDS UPGRADE',
+ ];
- $dbState = [
- 'state' => 'UP',
- 'version' => $version,
- ];
+ $db->disconnect();
} catch (\Exception $e) {
$dbState = [
@@ -114,31 +118,16 @@ class Status
$updater = new Update();
- $version = $updater->getDbVersion($adminDb);
-
- Logger::debug("Need DB-Version: " . Update::SUPPORTED_VERSION . "; Actual DB-Version: " . $version);
-
- if ($version == Update::SUPPORTED_VERSION)
-
- // Cool, der aktuelle DB-Stand passt zu dieser Version. Das ist auch der Normalfall. Weiter so.
- $dbState = [
- 'state' => 'UP',
- 'version' => $version,
- ];
-
- elseif ($version > Update::SUPPORTED_VERSION)
- // Oh oh, in der Datenbank ist eine neuere Version, als wir unterstützen.
+ if ( ! $updater->isUpdateRequired( $adminDb ) ) {
$dbState = [
- 'state' => 'DOWN',
- 'version' => $version,
- 'message' => 'Actual DB version is not supported. ' . "DB-Version is $version, but " . Startup::VERSION . " only supports version " . Update::SUPPORTED_VERSION,
+ 'state' => 'UP',
];
+ }
else {
if (!$dbConfig->is('auto_update', true))
$dbState = [
'state' => 'DOWN',
- 'version' => $version,
'message' => 'DB Update required, but auto-update is disabled. ' . Startup::TITLE . " " . Startup::VERSION . " needs DB-version " . Update::SUPPORTED_VERSION
];
else {
@@ -159,8 +148,6 @@ class Status
'state' => 'DOWN',
'message' => $e->getMessage(),
];
-
- break;
}
}
@@ -178,7 +165,6 @@ class Status
'date' => Startup::DATE,
'name' => Startup::TITLE,
'api' => Startup::API_LEVEL,
- 'supportedDatabaseVersion' => Update::SUPPORTED_VERSION,
];
$success = true;
break;
diff --git a/modules/cms/update/Update.class.php b/modules/cms/update/Update.class.php
@@ -94,7 +94,7 @@ class Update
* @param Database $db
* @return int
*/
- public function getDbVersion(Database $db)
+ private function getDbVersion(Database $db)
{
$versionTableExists = $this->testQuery($db, 'SELECT 1 FROM {{version}}');