diff --git a/Modules/Chatroom/classes/Setup/class.ilChatroomMetricsCollectedObjective.php b/Modules/Chatroom/classes/Setup/class.ilChatroomMetricsCollectedObjective.php index 6b4398e8b9fa..31cf1f2552f4 100644 --- a/Modules/Chatroom/classes/Setup/class.ilChatroomMetricsCollectedObjective.php +++ b/Modules/Chatroom/classes/Setup/class.ilChatroomMetricsCollectedObjective.php @@ -41,160 +41,163 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto // fact, that dependency injection is something we want. Currently, every // component could just service locate the whole world via the global $DIC. $DIC = $GLOBALS["DIC"]; - $GLOBALS["DIC"] = new DI\Container(); - $GLOBALS["DIC"]["ilDB"] = $db; - $GLOBALS["DIC"]["ilBench"] = null; - - $chatAdministrations = ilObject::_getObjectsByType('chta'); - $chatAdministration = current($chatAdministrations); - - $chat_admin = new ilChatroomAdmin((int) $chatAdministration['obj_id']); - $settings = $chat_admin->loadGeneralSettings(); - - if (count($settings) > 0) { - $storage->storeConfigText( - "address", - $settings['address'] ?? "", - "IP-Address/FQN of Chat Server." - ); - $storage->storeConfigText( - "port", - (string) ($settings['port'] ?? ""), - "Port of the chat server." - ); - $storage->storeConfigText( - "sub_directory", - $settings['sub_directory'] ?? "", - "http(s)://[IP/Domain]/[SUB_DIRECTORY]" - ); - - $storage->storeConfigText( - "protocol", - $settings['protocol'] ?? "", - "Protocol used for connection (http/https)." - ); - - if ($settings['protocol'] === 'https') { - $cert = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['cert'] ?? "" + try { + $GLOBALS["DIC"] = new DI\Container(); + $GLOBALS["DIC"]["ilDB"] = $db; + $GLOBALS["DIC"]["ilBench"] = null; + + $chatAdministrations = ilObject::_getObjectsByType('chta'); + $chatAdministration = current($chatAdministrations); + + $chat_admin = new ilChatroomAdmin((int) $chatAdministration['obj_id']); + $settings = $chat_admin->loadGeneralSettings(); + + if (count($settings) > 0) { + $storage->storeConfigText( + "address", + $settings['address'] ?? "", + "IP-Address/FQN of Chat Server." ); - $key = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['key'] ?? "" + $storage->storeConfigText( + "port", + (string) ($settings['port'] ?? ""), + "Port of the chat server." ); - $dhparam = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['dhparam'] ?? "" + $storage->storeConfigText( + "sub_directory", + $settings['sub_directory'] ?? "", + "http(s)://[IP/Domain]/[SUB_DIRECTORY]" ); - $https = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ - "cert" => $cert, - "key" => $key, - "dhparam" => $dhparam, - ], - "Holds parameters for https." - ); - $storage->store("https", $https); - } - $storage->storeConfigText( - "log", - (string) ($settings['log'] ?? ''), - "Absolute server path to the chat server's log file." - ); - $storage->storeConfigText( - "log_level", - $settings['log_level'] ?? "", - "Possible values are emerg, alert, crit error, warning, notice, info, debug, silly." - ); - $storage->storeConfigText( - "error_log", - $settings['error_log'] ?? "", - "Absolute server path to the chat server's error log file." - ); - - if ($settings['ilias_proxy']) { - $ilias_url = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['ilias_url'] ?? "" - ); - $ilias_proxy = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ - "ilias_url" => $ilias_url - ], - "Holds proxy url if ILIAS proxy is enabled." + $storage->storeConfigText( + "protocol", + $settings['protocol'] ?? "", + "Protocol used for connection (http/https)." ); - $storage->store("ilias_proxy", $ilias_proxy); - } else { - $storage->storeConfigBool( - "ilias_proxy", - false, - "Holds proxy url if ILIAS proxy is enabled." - ); - } - if ($settings['client_proxy']) { - $client_url = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['client_url'] ?? "" + if ($settings['protocol'] === 'https') { + $cert = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_TEXT, + $settings['cert'] ?? "" + ); + $key = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_TEXT, + $settings['key'] ?? "" + ); + $dhparam = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_TEXT, + $settings['dhparam'] ?? "" + ); + $https = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_COLLECTION, + [ + "cert" => $cert, + "key" => $key, + "dhparam" => $dhparam, + ], + "Holds parameters for https." + ); + $storage->store("https", $https); + } + + $storage->storeConfigText( + "log", + (string) ($settings['log'] ?? ''), + "Absolute server path to the chat server's log file." ); - $client_proxy = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ - "client_url" => $client_url - ], - "Holds proxy url if client proxy is enabled." + $storage->storeConfigText( + "log_level", + $settings['log_level'] ?? "", + "Possible values are emerg, alert, crit error, warning, notice, info, debug, silly." ); - $storage->store("client_proxy", $client_proxy); - } else { - $storage->storeConfigBool( - "client_proxy", - false, - "Holds proxy url if client proxy is enabled." + $storage->storeConfigText( + "error_log", + $settings['error_log'] ?? "", + "Absolute server path to the chat server's error log file." ); - } - if ($settings['deletion_mode']) { - $deletion_unit = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['deletion_unit'] ?? "" - ); - $deletion_value = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - (string) ($settings['deletion_value'] ?? '') - ); - $deletion_time = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['deletion_time'] ?? "" - ); - $deletion_mode = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ - "deletion_unit" => $deletion_unit, - "deletion_value" => $deletion_value, - "deletion_time" => $deletion_time, - ], - "Holds information about deletion process." - ); - $storage->store("deletion_mode", $deletion_mode); + if ($settings['ilias_proxy']) { + $ilias_url = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_TEXT, + $settings['ilias_url'] ?? "" + ); + $ilias_proxy = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_COLLECTION, + [ + "ilias_url" => $ilias_url + ], + "Holds proxy url if ILIAS proxy is enabled." + ); + $storage->store("ilias_proxy", $ilias_proxy); + } else { + $storage->storeConfigBool( + "ilias_proxy", + false, + "Holds proxy url if ILIAS proxy is enabled." + ); + } + + if ($settings['client_proxy']) { + $client_url = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_TEXT, + $settings['client_url'] ?? "" + ); + $client_proxy = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_COLLECTION, + [ + "client_url" => $client_url + ], + "Holds proxy url if client proxy is enabled." + ); + $storage->store("client_proxy", $client_proxy); + } else { + $storage->storeConfigBool( + "client_proxy", + false, + "Holds proxy url if client proxy is enabled." + ); + } + + if ($settings['deletion_mode']) { + $deletion_unit = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_TEXT, + $settings['deletion_unit'] ?? "" + ); + $deletion_value = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_TEXT, + (string) ($settings['deletion_value'] ?? '') + ); + $deletion_time = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_TEXT, + $settings['deletion_time'] ?? "" + ); + $deletion_mode = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_COLLECTION, + [ + "deletion_unit" => $deletion_unit, + "deletion_value" => $deletion_value, + "deletion_time" => $deletion_time, + ], + "Holds information about deletion process." + ); + $storage->store("deletion_mode", $deletion_mode); + } } } - - $GLOBALS["DIC"] = $DIC; + finally { + $GLOBALS["DIC"] = $DIC; + } } } diff --git a/Services/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php b/Services/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php index 3b7f6548434c..a507cb3b6832 100644 --- a/Services/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php +++ b/Services/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php @@ -83,115 +83,118 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto // is something we want. Currently, every component could just service // locate the whole world via the global $DIC. $DIC = $GLOBALS["DIC"] ?? []; - $GLOBALS["DIC"] = new DI\Container(); - $GLOBALS["DIC"]["ilDB"] = $db; - $GLOBALS["ilDB"] = $db; - $GLOBALS["DIC"]["ilBench"] = null; - $GLOBALS["DIC"]["ilLog"] = new class () { - public function write(): void - { + try { + $GLOBALS["DIC"] = new DI\Container(); + $GLOBALS["DIC"]["ilDB"] = $db; + $GLOBALS["ilDB"] = $db; + $GLOBALS["DIC"]["ilBench"] = null; + $GLOBALS["DIC"]["ilLog"] = new class () { + public function write(): void + { + } + public function info(): void + { + } + public function warning($msg): void + { + } + public function error($msg): void + { + } + }; + $GLOBALS["ilLog"] = $GLOBALS["DIC"]["ilLog"]; + /** @noinspection PhpArrayIndexImmediatelyRewrittenInspection */ + $GLOBALS["DIC"]["ilLoggerFactory"] = new class () { + public function getRootLogger(): object + { + return new class () { + public function write(): void + { + } + }; + } + }; + $GLOBALS["ilCtrlStructureReader"] = new class () { + public function getStructure(): void + { + } + public function setIniFile(): void + { + } + }; + if (!defined("CLIENT_DATA_DIR")) { + define("CLIENT_DATA_DIR", $ini->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( - "version", - $db_update->getCurrentVersion(), - "The version of the database schema that is currently installed." - ); - $storage->storeStableCounter( - "available_version", - $db_update->getFileVersion(), - "The version of the database schema that is available in the current source." - ); - $storage->storeStableBool( - "update_required", - !$db_update->getDBVersionStatus(), - "Does the database require an update?" - ); - $storage->storeStableCounter( - "hotfix_version", - $db_update->getHotfixCurrentVersion() ?? 0, - "The version of the hotfix database schema that is currently installed." - ); - $storage->storeStableCounter( - "available_hotfix_version", - $db_update->getHotfixFileVersion() ?? 0, - "The version of the hotfix database schema that is available in the current source." - ); - $storage->storeStableBool( - "hotfix_required", - $db_update->hotfixAvailable(), - "Does the database require a hotfix update?" - ); - $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); + $db_update->readCustomUpdatesInfo(true); - $GLOBALS["DIC"] = $DIC; + $storage->storeStableCounter( + "version", + $db_update->getCurrentVersion(), + "The version of the database schema that is currently installed." + ); + $storage->storeStableCounter( + "available_version", + $db_update->getFileVersion(), + "The version of the database schema that is available in the current source." + ); + $storage->storeStableBool( + "update_required", + !$db_update->getDBVersionStatus(), + "Does the database require an update?" + ); + $storage->storeStableCounter( + "hotfix_version", + $db_update->getHotfixCurrentVersion() ?? 0, + "The version of the hotfix database schema that is currently installed." + ); + $storage->storeStableCounter( + "available_hotfix_version", + $db_update->getHotfixFileVersion() ?? 0, + "The version of the hotfix database schema that is available in the current source." + ); + $storage->storeStableBool( + "hotfix_required", + $db_update->hotfixAvailable(), + "Does the database require a hotfix update?" + ); + $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..9cbe4dd05fce 100644 --- a/Services/GlobalCache/classes/Setup/class.ilGlobalCacheMetricsCollectedObjective.php +++ b/Services/GlobalCache/classes/Setup/class.ilGlobalCacheMetricsCollectedObjective.php @@ -42,94 +42,97 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto // fact, that dependency injection is something we want. Currently, every // component could just service locate the whole world via the global $DIC. $DIC = $GLOBALS["DIC"]; - $GLOBALS["DIC"] = new DI\Container(); - /** @noinspection PhpArrayIndexImmediatelyRewrittenInspection */ - $GLOBALS["DIC"]["ilDB"] = $db; + try { + $GLOBALS["DIC"] = new DI\Container(); + /** @noinspection PhpArrayIndexImmediatelyRewrittenInspection */ + $GLOBALS["DIC"]["ilDB"] = $db; - $settings = new ilGlobalCacheSettings(); - $settings->readFromIniFile($client_ini); + $settings = new ilGlobalCacheSettings(); + $settings->readFromIniFile($client_ini); - $service_type = (int) $settings->getService(); - $service = ilGlobalCache::lookupServiceConfigName($service_type); - $storage->storeConfigText( - "service", - $service, - "The backend that is used for the ILIAS cache." - ); - $storage->storeConfigBool( - "active", - (bool) $settings->isActive() - ); + $service_type = (int) $settings->getService(); + $service = ilGlobalCache::lookupServiceConfigName($service_type); + $storage->storeConfigText( + "service", + $service, + "The backend that is used for the ILIAS cache." + ); + $storage->storeConfigBool( + "active", + (bool) $settings->isActive() + ); - $servers = ilMemcacheServer::get(); - if ( - $service_type === ilGlobalCache::TYPE_MEMCACHED && - count($servers) > 0 - ) { - $server_collection = []; - foreach ($servers as $server) { - $active = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_BOOL, - $server->isActive() - ); - $host = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $server->getHost() - ); - $port = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_GAUGE, - $server->getPort() - ); - $weight = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_GAUGE, - $server->getWeight() - ); + $servers = ilMemcacheServer::get(); + if ( + $service_type === ilGlobalCache::TYPE_MEMCACHED && + count($servers) > 0 + ) { + $server_collection = []; + foreach ($servers as $server) { + $active = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_BOOL, + $server->isActive() + ); + $host = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_TEXT, + $server->getHost() + ); + $port = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_GAUGE, + $server->getPort() + ); + $weight = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_GAUGE, + $server->getWeight() + ); - $server_collection[] = new Setup\Metrics\Metric( + $server_collection[] = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_COLLECTION, + [ + "active" => $active, + "host" => $host, + "port" => $port, + "weight" => $weight + ], + "Configured memcached node." + ); + } + + $nodes = new Setup\Metrics\Metric( Setup\Metrics\Metric::STABILITY_CONFIG, Setup\Metrics\Metric::TYPE_COLLECTION, - [ - "active" => $active, - "host" => $host, - "port" => $port, - "weight" => $weight - ], - "Configured memcached node." + $server_collection, + "Collection of configured memcached nodes." ); + $storage->store("memcached_nodes", $nodes); } - $nodes = new Setup\Metrics\Metric( + $component_activation = []; + foreach (ilGlobalCache::getAvailableComponents() as $component) { + $component_activation[$component] = new Setup\Metrics\Metric( + Setup\Metrics\Metric::STABILITY_CONFIG, + Setup\Metrics\Metric::TYPE_BOOL, + $settings->isComponentActivated($component) + ); + } + $component_activation = new Setup\Metrics\Metric( Setup\Metrics\Metric::STABILITY_CONFIG, Setup\Metrics\Metric::TYPE_COLLECTION, - $server_collection, - "Collection of configured memcached nodes." + $component_activation, + "Which components are activated to use caching?" ); - $storage->store("memcached_nodes", $nodes); - } - - $component_activation = []; - foreach (ilGlobalCache::getAvailableComponents() as $component) { - $component_activation[$component] = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_BOOL, - $settings->isComponentActivated($component) + $storage->store( + "components", + $component_activation ); } - $component_activation = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - $component_activation, - "Which components are activated to use caching?" - ); - $storage->store( - "components", - $component_activation - ); - - $GLOBALS["DIC"] = $DIC; + finally { + $GLOBALS["DIC"] = $DIC; + } } }