From b803fabaa8c0cc0035898118a0fb9811896fb540 Mon Sep 17 00:00:00 2001 From: Richard Klees Date: Mon, 8 Jan 2024 17:25:05 +0100 Subject: [PATCH] Database: Fix Metric Objective Resolved initial error, which is access to a private method, and also made the objective more fail safe. See: * https://github.com/ILIAS-eLearning/ILIAS/pull/6801 * https://mantis.ilias.de/view.php?id=39355 --- ...ss.ilDatabaseMetricsCollectedObjective.php | 137 ++++++++---------- ...ilGlobalCacheMetricsCollectedObjective.php | 1 + 2 files changed, 65 insertions(+), 73 deletions(-) diff --git a/Services/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php b/Services/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php index 37643a21826f..fa043f248bee 100644 --- a/Services/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php +++ b/Services/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php @@ -1,7 +1,5 @@ readVariable("clients", "datadir") . "/" . $client_id); } - public function info(): void - { + if (!defined("CLIENT_WEB_DIR")) { + define("CLIENT_WEB_DIR", dirname(__DIR__, 4) . "/data/" . $client_id); } - public function warning($msg): void - { + if (!defined("ILIAS_ABSOLUTE_PATH")) { + define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5)); } - public function error($msg): void - { + if (!defined("ILIAS_LOG_ENABLED")) { + define("ILIAS_LOG_ENABLED", false); } - }; - $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"]; - /** @noinspection PhpArrayIndexImmediatelyRewrittenInspection */ - $GLOBALS["DIC"]["ilLoggerFactory"] = new class () { - public function getRootLogger(): object - { - return new class () { - public function write(): void - { - } - }; + if (!defined("ROOT_FOLDER_ID")) { + define("ROOT_FOLDER_ID", (int) $client_ini->readVariable("system", "ROOT_FOLDER_ID")); } - }; - $GLOBALS["ilCtrlStructureReader"] = new class () { - public function getStructure(): void - { + if (!defined("ROLE_FOLDER_ID")) { + define("ROLE_FOLDER_ID", (int) $client_ini->readVariable("system", "ROLE_FOLDER_ID")); } - public function setIniFile(): void - { + if (!defined("SYSTEM_FOLDER_ID")) { + define("SYSTEM_FOLDER_ID", (int) $client_ini->readVariable("system", "SYSTEM_FOLDER_ID")); } - }; - if (!defined("CLIENT_DATA_DIR")) { - define("CLIENT_DATA_DIR", $ini->readVariable("clients", "datadir") . "/" . $client_id); - } - if (!defined("CLIENT_WEB_DIR")) { - define("CLIENT_WEB_DIR", dirname(__DIR__, 4) . "/data/" . $client_id); - } - if (!defined("ILIAS_ABSOLUTE_PATH")) { - define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5)); - } - if (!defined("ILIAS_LOG_ENABLED")) { - define("ILIAS_LOG_ENABLED", false); - } - if (!defined("ROOT_FOLDER_ID")) { - define("ROOT_FOLDER_ID", (int) $client_ini->readVariable("system", "ROOT_FOLDER_ID")); - } - if (!defined("ROLE_FOLDER_ID")) { - define("ROLE_FOLDER_ID", (int) $client_ini->readVariable("system", "ROLE_FOLDER_ID")); - } - if (!defined("SYSTEM_FOLDER_ID")) { - define("SYSTEM_FOLDER_ID", (int) $client_ini->readVariable("system", "SYSTEM_FOLDER_ID")); - } - - $db_update = new ilDBUpdate($db); - $db_update->readCustomUpdatesInfo(true); - $storage->storeStableCounter( - "custom_version", - $db_update->getCustomUpdatesCurrentVersion() ?? 0, - "The version of the custom database schema that is currently installed." - ); - $storage->storeStableCounter( - "available_custom_version", - $db_update->getCustomUpdatesFileVersion() ?? 0, - "The version of the custom database schema that is available in the current source." - ); - $storage->storeStableBool( - "custom_update_required", - $db_update->customUpdatesAvailable(), - "Does the database require a custom update?" - ); + $db_update = new ilDBUpdate($db); - $GLOBALS["DIC"] = $DIC; + $storage->storeStableCounter( + "custom_version", + $db_update->getCustomUpdatesCurrentVersion() ?? 0, + "The version of the custom database schema that is currently installed." + ); + $storage->storeStableCounter( + "available_custom_version", + $db_update->getCustomUpdatesFileVersion() ?? 0, + "The version of the custom database schema that is available in the current source." + ); + $storage->storeStableBool( + "custom_update_required", + $db_update->customUpdatesAvailable(), + "Does the database require a custom update?" + ); + } finally { + $GLOBALS["DIC"] = $DIC; + } } } diff --git a/Services/GlobalCache/classes/Setup/class.ilGlobalCacheMetricsCollectedObjective.php b/Services/GlobalCache/classes/Setup/class.ilGlobalCacheMetricsCollectedObjective.php index be2141a0ab22..70e6fb45d6e0 100644 --- a/Services/GlobalCache/classes/Setup/class.ilGlobalCacheMetricsCollectedObjective.php +++ b/Services/GlobalCache/classes/Setup/class.ilGlobalCacheMetricsCollectedObjective.php @@ -30,6 +30,7 @@ protected function getTentativePreconditions(Setup\Environment $environment): ar protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage): void { + return; $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE); $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);