diff --git a/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksMetricsCollectedObjective.php b/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksMetricsCollectedObjective.php index 41f87b17fab1..398b6d029bb0 100755 --- a/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksMetricsCollectedObjective.php +++ b/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksMetricsCollectedObjective.php @@ -39,12 +39,12 @@ public function collectFrom(Setup\Environment $environment, Setup\Metrics\Storag $storage->storeConfigText( "type", - $ini->readVariable("background_tasks", "concurrency"), + fn() => $ini->readVariable("background_tasks", "concurrency"), "The type of execution used for background tasks" ); $storage->storeConfigGauge( "max_number_of_concurrent_tasks", - (int) $ini->readVariable("background_tasks", "number_of_concurrent_tasks"), + fn() => (int) $ini->readVariable("background_tasks", "number_of_concurrent_tasks"), "The maximum amount of concurrent tasks used to run background tasks." ); } diff --git a/components/ILIAS/Chatroom/classes/Setup/class.ilChatroomMetricsCollectedObjective.php b/components/ILIAS/Chatroom/classes/Setup/class.ilChatroomMetricsCollectedObjective.php index bd08849f5ce6..1a933ddd56ba 100755 --- a/components/ILIAS/Chatroom/classes/Setup/class.ilChatroomMetricsCollectedObjective.php +++ b/components/ILIAS/Chatroom/classes/Setup/class.ilChatroomMetricsCollectedObjective.php @@ -54,46 +54,46 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto if (count($settings) > 0) { $storage->storeConfigText( 'address', - $settings['address'] ?? '', + fn() => $settings['address'] ?? '', 'IP-Address/FQN of Chat Server.' ); $storage->storeConfigText( 'port', - (string) ($settings['port'] ?? ''), + fn() => (string) ($settings['port'] ?? ''), 'Port of the chat server.' ); $storage->storeConfigText( 'sub_directory', - $settings['sub_directory'] ?? '', + fn() => $settings['sub_directory'] ?? '', 'http(s)://[IP/Domain]/[SUB_DIRECTORY]' ); $storage->storeConfigText( 'protocol', - $settings['protocol'] ?? '', + fn() => $settings['protocol'] ?? '', 'Protocol used for connection (http/https).' ); if (isset($settings['protocol']) && $settings['protocol'] === 'https') { $cert = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['cert'] ?? '' + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings['cert'] ?? '' ); $key = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['key'] ?? '' + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings['key'] ?? '' ); $dhparam = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['dhparam'] ?? '' + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings['dhparam'] ?? '' ); $https = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::COLLECTION, + fn() => [ 'cert' => $cert, 'key' => $key, 'dhparam' => $dhparam, @@ -105,30 +105,30 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto $storage->storeConfigText( 'log', - (string) ($settings['log'] ?? ''), + fn() => (string) ($settings['log'] ?? ''), "Absolute server path to the chat server's log file." ); $storage->storeConfigText( 'log_level', - $settings['log_level'] ?? '', + fn() => $settings['log_level'] ?? '', 'Possible values are emerg, alert, crit error, warning, notice, info, debug, silly.' ); $storage->storeConfigText( 'error_log', - $settings['error_log'] ?? '', + fn() => $settings['error_log'] ?? '', "Absolute server path to the chat server's error log file." ); if (isset($settings['ilias_proxy']) && $settings['ilias_proxy']) { $ilias_url = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['ilias_url'] ?? '' + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings['ilias_url'] ?? '' ); $ilias_proxy = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::COLLECTION, + fn() => [ 'ilias_url' => $ilias_url ], 'Holds proxy url if ILIAS proxy is enabled.' @@ -137,21 +137,21 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto } else { $storage->storeConfigBool( 'ilias_proxy', - false, + fn() => false, 'Holds proxy url if ILIAS proxy is enabled.' ); } if (isset($settings['client_proxy']) && $settings['client_proxy']) { $client_url = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['client_url'] ?? '' + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings['client_url'] ?? '' ); $client_proxy = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::COLLECTION, + fn() => [ 'client_url' => $client_url ], 'Holds proxy url if client proxy is enabled.' @@ -160,31 +160,31 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto } else { $storage->storeConfigBool( 'client_proxy', - false, + fn() => false, 'Holds proxy url if client proxy is enabled.' ); } if (isset($settings['deletion_mode']) && $settings['deletion_mode']) { $deletion_unit = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['deletion_unit'] ?? '' + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings['deletion_unit'] ?? '' ); $deletion_value = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - (string) ($settings['deletion_value'] ?? '') + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => (string) ($settings['deletion_value'] ?? '') ); $deletion_time = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings['deletion_time'] ?? '' + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings['deletion_time'] ?? '' ); $deletion_mode = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::COLLECTION, + fn() => [ 'deletion_unit' => $deletion_unit, 'deletion_value' => $deletion_value, 'deletion_time' => $deletion_time, diff --git a/components/ILIAS/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php b/components/ILIAS/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php index fa043f248bee..eb5441d09d69 100755 --- a/components/ILIAS/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php +++ b/components/ILIAS/Database/classes/Setup/class.ilDatabaseMetricsCollectedObjective.php @@ -40,32 +40,32 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto if ($client_ini) { $storage->storeConfigText( "type", - $client_ini->readVariable("db", "type") ?? "mysql", + fn() => $client_ini->readVariable("db", "type") ?? "mysql", "The storage backend that is used for the database." ); $storage->storeConfigText( "host", - $client_ini->readVariable("db", "host"), + fn() => $client_ini->readVariable("db", "host"), "The host where the storage backend is located." ); $storage->storeConfigText( "port", - $client_ini->readVariable("db", "port"), + fn() => $client_ini->readVariable("db", "port"), "The port where the storage backend is located at the host." ); $storage->storeConfigText( "name", - $client_ini->readVariable("db", "name"), + fn() => $client_ini->readVariable("db", "name"), "The name of the database in the storage backend." ); $storage->storeConfigText( "user", - $client_ini->readVariable("db", "user"), + fn() => $client_ini->readVariable("db", "user"), "The user to be used for the storage backend." ); $storage->storeConfigText( "pass", - PHP_SAPI === 'cli' ? $client_ini->readVariable("db", "pass") : '********', + fn() => PHP_SAPI === 'cli' ? $client_ini->readVariable("db", "pass") : '********', "The password for the user for the storage backend." ); } @@ -138,17 +138,17 @@ public function write(): void $storage->storeStableCounter( "custom_version", - $db_update->getCustomUpdatesCurrentVersion() ?? 0, + fn() => $db_update->getCustomUpdatesCurrentVersion() ?? 0, "The version of the custom database schema that is currently installed." ); $storage->storeStableCounter( "available_custom_version", - $db_update->getCustomUpdatesFileVersion() ?? 0, + fn() => $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(), + fn() => $db_update->customUpdatesAvailable(), "Does the database require a custom update?" ); } finally { diff --git a/components/ILIAS/Database/classes/Setup/class.ilDatabaseUpdateStepsMetricsCollectedObjective.php b/components/ILIAS/Database/classes/Setup/class.ilDatabaseUpdateStepsMetricsCollectedObjective.php index 5cbfdb17fd1f..17636df3e90a 100755 --- a/components/ILIAS/Database/classes/Setup/class.ilDatabaseUpdateStepsMetricsCollectedObjective.php +++ b/components/ILIAS/Database/classes/Setup/class.ilDatabaseUpdateStepsMetricsCollectedObjective.php @@ -1,7 +1,5 @@ getResource(ilDBStepReader::class); $version = new Metric( - Metric::STABILITY_STABLE, - Metric::TYPE_TEXT, - (string) ($execution_log->getLastFinishedStep($this->step_class)) + Setup\Metrics\MetricStability::STABLE, + Setup\Metrics\MetricType::TEXT, + fn() => (string) ($execution_log->getLastFinishedStep($this->step_class)) ); $available_version = new Metric( - Metric::STABILITY_STABLE, - Metric::TYPE_TEXT, - (string) $step_reader->getLatestStepNumber($this->step_class, self::STEP_METHOD_PREFIX) + Setup\Metrics\MetricStability::STABLE, + Setup\Metrics\MetricType::TEXT, + fn() => (string) $step_reader->getLatestStepNumber($this->step_class, self::STEP_METHOD_PREFIX) ); $update_required = new Metric( - Metric::STABILITY_STABLE, - Metric::TYPE_BOOL, - $execution_log->getLastFinishedStep($this->step_class) !== $step_reader->getLatestStepNumber( + Setup\Metrics\MetricStability::STABLE, + Setup\Metrics\MetricType::BOOL, + fn() => $execution_log->getLastFinishedStep($this->step_class) !== $step_reader->getLatestStepNumber( $this->step_class, self::STEP_METHOD_PREFIX ) ); $collection = new Metric( - Metric::STABILITY_STABLE, - Metric::TYPE_COLLECTION, - [ + Setup\Metrics\MetricStability::STABLE, + Setup\Metrics\MetricType::COLLECTION, + fn() => [ "version" => $version, "available_version" => $available_version, "update_required" => $update_required diff --git a/components/ILIAS/Filesystem/classes/Setup/class.ilFileSystemMetricsCollectedObjective.php b/components/ILIAS/Filesystem/classes/Setup/class.ilFileSystemMetricsCollectedObjective.php index 76d188295d1a..56458fe50449 100755 --- a/components/ILIAS/Filesystem/classes/Setup/class.ilFileSystemMetricsCollectedObjective.php +++ b/components/ILIAS/Filesystem/classes/Setup/class.ilFileSystemMetricsCollectedObjective.php @@ -37,7 +37,7 @@ protected function collectFrom(Setup\Environment $environment, Storage $storage) if ($ini) { $storage->storeConfigText( "data_dir", - $ini->readVariable("clients", "datadir"), + fn() => $ini->readVariable("clients", "datadir"), "Filesystem location where ILIAS stores data outside of direct web access." ); } diff --git a/components/ILIAS/GlobalCache_/classes/Setup/class.ilGlobalCacheMetricsCollectedObjective.php b/components/ILIAS/GlobalCache_/classes/Setup/class.ilGlobalCacheMetricsCollectedObjective.php index 63f2c5806175..2dd8715e3bdf 100755 --- a/components/ILIAS/GlobalCache_/classes/Setup/class.ilGlobalCacheMetricsCollectedObjective.php +++ b/components/ILIAS/GlobalCache_/classes/Setup/class.ilGlobalCacheMetricsCollectedObjective.php @@ -21,6 +21,8 @@ use ILIAS\Setup\Metrics\Storage; use ILIAS\Cache\Config; use ILIAS\Setup\Metrics\Metric; +use ILIAS\Setup\Metrics\MetricStability; +use ILIAS\Setup\Metrics\MetricType; use ILIAS\Setup; class ilGlobalCacheMetricsCollectedObjective extends CollectedObjective @@ -47,12 +49,12 @@ protected function collectFrom(Environment $environment, Storage $storage): void $service = $config->getAdaptorName(); $storage->storeConfigText( "service", - $service, + fn() => $service, "The backend that is used for the ILIAS cache." ); $storage->storeConfigBool( "active", - $config->isActivated() + fn() => $config->isActivated() ); $servers = $config->getNodes(); @@ -63,25 +65,25 @@ protected function collectFrom(Environment $environment, Storage $storage): void $server_collection = []; foreach ($servers as $server) { $host = new Metric( - Metric::STABILITY_CONFIG, - Metric::TYPE_TEXT, - $server->getHost() + MetricStability::CONFIG, + MetricType::TEXT, + fn() => $server->getHost() ); $port = new Metric( - Metric::STABILITY_CONFIG, - Metric::TYPE_GAUGE, - $server->getPort() + MetricStability::CONFIG, + MetricType::GAUGE, + fn() => $server->getPort() ); $weight = new Metric( - Metric::STABILITY_CONFIG, - Metric::TYPE_GAUGE, - $server->getWeight() + MetricStability::CONFIG, + MetricType::GAUGE, + fn() => $server->getWeight() ); $server_collection[] = new Metric( - Metric::STABILITY_CONFIG, - Metric::TYPE_COLLECTION, - [ + MetricStability::CONFIG, + MetricType::COLLECTION, + fn() => [ "host" => $host, "port" => $port, "weight" => $weight @@ -91,9 +93,9 @@ protected function collectFrom(Environment $environment, Storage $storage): void } $nodes = new Metric( - Metric::STABILITY_CONFIG, - Metric::TYPE_COLLECTION, - $server_collection, + MetricStability::CONFIG, + MetricType::COLLECTION, + fn() => $server_collection, "Collection of configured memcached nodes." ); $storage->store("memcached_nodes", $nodes); @@ -102,15 +104,15 @@ protected function collectFrom(Environment $environment, Storage $storage): void $component_activation = []; foreach (ilGlobalCache::getAvailableComponents() as $component) { $component_activation[$component] = new Metric( - Metric::STABILITY_CONFIG, - Metric::TYPE_BOOL, - $config->isComponentActivated($component) + MetricStability::CONFIG, + MetricType::BOOL, + fn() => $config->isComponentActivated($component) ); } $component_activation = new Metric( - Metric::STABILITY_CONFIG, - Metric::TYPE_COLLECTION, - $component_activation, + MetricStability::CONFIG, + MetricType::COLLECTION, + fn() => $component_activation, "Which components are activated to use caching?" ); $storage->store( diff --git a/components/ILIAS/Http_/classes/Setup/class.ilHttpMetricsCollectedObjective.php b/components/ILIAS/Http_/classes/Setup/class.ilHttpMetricsCollectedObjective.php index 24f05d044d52..d5ff328726ca 100755 --- a/components/ILIAS/Http_/classes/Setup/class.ilHttpMetricsCollectedObjective.php +++ b/components/ILIAS/Http_/classes/Setup/class.ilHttpMetricsCollectedObjective.php @@ -1,20 +1,23 @@ storeConfigText( "http_path", - $ilias_ini->readVariable("server", "http_path"), + fn() => $ilias_ini->readVariable("server", "http_path"), "URL of the server." ); $storage->storeConfigText( "https forced", - $ilias_ini->readVariable("https", "forced"), + fn() => $ilias_ini->readVariable("https", "forced"), "" ); if ($ilias_ini->readVariable("https", "auto_https_detect_enabled")) { $header_name = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $ilias_ini->readVariable("https", "auto_https_detect_header_name"), + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $ilias_ini->readVariable("https", "auto_https_detect_header_name"), "The name of the header used for https detection in requests." ); $header_value = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $ilias_ini->readVariable("https", "auto_https_detect_header_value"), + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $ilias_ini->readVariable("https", "auto_https_detect_header_value"), "The value in the named header that indicates usage of https in requests." ); $https_metrics = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::COLLECTION, + fn() => [ "header_name" => $header_name, "header_value" => $header_value ], @@ -70,7 +73,7 @@ public function collectFrom(Setup\Environment $environment, Setup\Metrics\Storag } else { $storage->storeConfigBool( "https_autodetection", - false, + fn() => false, "Does the server attempt to detect https in incoming requests?" ); } @@ -84,21 +87,21 @@ public function collectFrom(Setup\Environment $environment, Setup\Metrics\Storag if ($settings->get("proxy_status")) { $host = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings->get("proxy_host"), + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings->get("proxy_host"), "The host of the proxy." ); $port = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings->get("proxy_port"), + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings->get("proxy_port"), "The port of the proxy." ); $proxy = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::COLLECTION, + fn() => [ "host" => $host, "port" => $port ], @@ -108,7 +111,7 @@ public function collectFrom(Setup\Environment $environment, Setup\Metrics\Storag } else { $storage->storeConfigBool( "proxy", - false, + fn() => false, "Does the server use a proxy for outgoing connections?" ); } diff --git a/components/ILIAS/Language/classes/Setup/class.ilLanguageMetricsCollectedObjective.php b/components/ILIAS/Language/classes/Setup/class.ilLanguageMetricsCollectedObjective.php index e211bb9c0bb4..bdc86abd0e37 100755 --- a/components/ILIAS/Language/classes/Setup/class.ilLanguageMetricsCollectedObjective.php +++ b/components/ILIAS/Language/classes/Setup/class.ilLanguageMetricsCollectedObjective.php @@ -1,7 +1,5 @@ storeConfigText( "default_language", - $client_ini->readVariable("language", "default"), + fn() => $client_ini->readVariable("language", "default"), "The language that is used by default." ); } @@ -72,30 +72,30 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto $local_languages = $this->il_setup_language->getLocalLanguages(); foreach ($this->il_setup_language->getInstalledLanguages() as $lang) { $local_file = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_STABLE, - Setup\Metrics\Metric::TYPE_BOOL, - in_array($lang, $local_languages, true), + Setup\Metrics\MetricStability::STABLE, + Setup\Metrics\MetricType::BOOL, + fn() => in_array($lang, $local_languages, true), "Is there a local language file for the language?" ); $local_changes = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_STABLE, - Setup\Metrics\Metric::TYPE_BOOL, - count($this->il_setup_language->getLocalChanges($lang)) > 0, + Setup\Metrics\MetricStability::STABLE, + Setup\Metrics\MetricType::BOOL, + fn() => count($this->il_setup_language->getLocalChanges($lang)) > 0, "Are there local changes for the language?" ); $installed_languages[$lang] = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_STABLE, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ + Setup\Metrics\MetricStability::STABLE, + Setup\Metrics\MetricType::COLLECTION, + fn() => [ "local_file" => $local_file, "local_changes" => $local_changes ] ); } $installed_languages = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_STABLE, - Setup\Metrics\Metric::TYPE_COLLECTION, - $installed_languages + Setup\Metrics\MetricStability::STABLE, + Setup\Metrics\MetricType::COLLECTION, + fn() => $installed_languages ); $storage->store( "installed_languages", diff --git a/components/ILIAS/Logging/classes/Setup/class.ilLoggingMetricsCollectedObjective.php b/components/ILIAS/Logging/classes/Setup/class.ilLoggingMetricsCollectedObjective.php index d8beb7f56a61..b5f18d6a48ee 100755 --- a/components/ILIAS/Logging/classes/Setup/class.ilLoggingMetricsCollectedObjective.php +++ b/components/ILIAS/Logging/classes/Setup/class.ilLoggingMetricsCollectedObjective.php @@ -1,5 +1,21 @@ Extended GPL, see docs/LICENSE */ @@ -26,17 +42,17 @@ protected function collectFrom(Environment $environment, Storage $storage): void $storage->storeConfigBool( "enable", - (bool) $ini->readVariable("log", "enabled"), + fn() => (bool) $ini->readVariable("log", "enabled"), "Is the logging enabled on the installation?" ); $storage->storeConfigText( "path_to_logfile", - $ini->readVariable("log", "path") . "/" . $ini->readVariable("log", "file"), + fn() => $ini->readVariable("log", "path") . "/" . $ini->readVariable("log", "file"), "The path to the logfile." ); $storage->storeConfigText( "errorlog_dir", - $ini->readVariable("log", "error_path"), + fn() => $ini->readVariable("log", "error_path"), "The path to the directory where error protocols are stored." ); } diff --git a/components/ILIAS/MathJax/classes/Setup/class.ilMathJaxMetricsCollectedObjective.php b/components/ILIAS/MathJax/classes/Setup/class.ilMathJaxMetricsCollectedObjective.php index 624465dfa7d6..5ad6b4f32221 100755 --- a/components/ILIAS/MathJax/classes/Setup/class.ilMathJaxMetricsCollectedObjective.php +++ b/components/ILIAS/MathJax/classes/Setup/class.ilMathJaxMetricsCollectedObjective.php @@ -39,9 +39,9 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto $setup_config = new ilMathJaxSetupConfig([]); foreach ($setup_config->getDataFromConfig($config) as $key => $value) { if (is_bool($value)) { - $storage->storeStableBool($key, $value); + $storage->storeStableBool($key, fn() => $value); } else { - $storage->storeStableText($key, (string) $value); + $storage->storeStableText($key, fn() => (string) $value); } } } diff --git a/components/ILIAS/MediaObjects/classes/Setup/class.ilMediaObjectMetricsCollectedObjective.php b/components/ILIAS/MediaObjects/classes/Setup/class.ilMediaObjectMetricsCollectedObjective.php index 84b1fa90442a..8dac61a9a905 100755 --- a/components/ILIAS/MediaObjects/classes/Setup/class.ilMediaObjectMetricsCollectedObjective.php +++ b/components/ILIAS/MediaObjects/classes/Setup/class.ilMediaObjectMetricsCollectedObjective.php @@ -39,7 +39,7 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto $storage->storeConfigText( "path_to_ffmpeg", - $ini->readVariable("tools", "ffmpeg"), + fn() => $ini->readVariable("tools", "ffmpeg"), "The path to the binary of ffmpeg to convert videos." ); } diff --git a/components/ILIAS/Setup/src/CLI/StatusCommand.php b/components/ILIAS/Setup/src/CLI/StatusCommand.php index 3ede02518571..2a26c72646e2 100755 --- a/components/ILIAS/Setup/src/CLI/StatusCommand.php +++ b/components/ILIAS/Setup/src/CLI/StatusCommand.php @@ -1,7 +1,5 @@ setDescription("Collect and show status information about the installation."); $this->configureCommandForPlugins(); + $this->addOption("filter", "f", InputOption::VALUE_REQUIRED, "filter for specific information"); } protected function execute(InputInterface $input, OutputInterface $output): int { $agent = $this->getRelevantAgent($input); - - $output->write($this->getMetrics($agent)->toYAML() . "\n"); + $filter = ""; + if ($input->hasOption("filter") && $input->getOption("filter") != "") { + $filter = $input->getOption("filter"); + } + $output->write($this->getMetrics($agent, $filter)->toYAML() . "\n"); return 0; } - public function getMetrics(Agent $agent): Metrics\Metric + public function getMetrics(Agent $agent, string $filter = ""): Metrics\Metric { // ATTENTION: Don't do this (in general), please have a look at the comment // in ilIniFilesLoadedObjective. @@ -76,20 +81,59 @@ public function getMetrics(Agent $agent): Metrics\Metric $this->achieveObjective($objective, $environment); $metric = $storage->asMetric(); - list($config, $other) = $metric->extractByStability(Metrics\Metric::STABILITY_CONFIG); - if ($other) { + + list($show_config_section, $metric) = $this->filter($filter, $metric); + + $type = Metrics\MetricType::COLLECTION; + list($config, $other) = $metric->extractByStability(Metrics\MetricStability::CONFIG); + $values = []; + if ($other && !$show_config_section) { $values = $other->getValue(); - } else { - $values = []; + $type = $metric->getType(); } + if ($config) { - $values["config"] = $config; + if ($show_config_section) { + $values = $config->getValue(); + $type = $config->getType(); + } else { + $values["config"] = $config; + } } return new Metrics\Metric( - Metrics\Metric::STABILITY_MIXED, - Metrics\Metric::TYPE_COLLECTION, - $values + Metrics\MetricStability::VOLATILE, + $type, + fn() => $values ); } + + protected function filter(string $filter, Metrics\Metric $metric): array + { + $show_config_section = false; + if ($filter != "") { + $filter = explode(".", $filter); + + if ($filter[0] === "config") { + array_shift($filter); + $show_config_section = true; + } else { + $show_config_section = false; + } + + while (count($filter) > 0) { + if ($metric->getType() !== Metrics\MetricType::COLLECTION) { + throw new \RuntimeException("Cannot find key..."); + } + + $current = array_shift($filter); + $metrics = $metric->getValue(); + if (!array_key_exists($current, $metrics)) { + throw new \RuntimeException("Cannot find key..."); + } + $metric = $metrics[$current]; + } + } + return array($show_config_section, $metric); + } } diff --git a/components/ILIAS/Setup/src/Metrics/ArrayStorage.php b/components/ILIAS/Setup/src/Metrics/ArrayStorage.php index c59ae401242f..ca892dec9902 100755 --- a/components/ILIAS/Setup/src/Metrics/ArrayStorage.php +++ b/components/ILIAS/Setup/src/Metrics/ArrayStorage.php @@ -1,7 +1,5 @@ array_map( function ($v) { if (is_array($v)) { return $this->doAsMetric($v); diff --git a/components/ILIAS/Setup/src/Metrics/Metric.php b/components/ILIAS/Setup/src/Metrics/Metric.php index 4349bc698527..2a433d2a27cb 100755 --- a/components/ILIAS/Setup/src/Metrics/Metric.php +++ b/components/ILIAS/Setup/src/Metrics/Metric.php @@ -1,7 +1,5 @@ checkStability($stability, $type); $this->checkType($type); - $this->checkValue($type, $value); - - $this->stability = $stability; - $this->type = $type; - $this->value = $value; - $this->description = $description; + if (!is_callable($value_producer)) { + throw new \InvalidArgumentException( + "Expected \$value_producer to be callable." + ); + } } - protected function checkStability(string $stability, string $type): void + protected function checkStability(MetricStability $stability, MetricType $type): void { if ( - $stability !== self::STABILITY_CONFIG - && $stability !== self::STABILITY_STABLE - && $stability !== self::STABILITY_VOLATILE - && !($stability === self::STABILITY_MIXED && $type === self::TYPE_COLLECTION) + $stability !== MetricStability::CONFIG + && $stability !== MetricStability::STABLE + && $stability !== MetricStability::VOLATILE + && !($stability === MetricStability::MIXED && $type === MetricType::COLLECTION) ) { throw new \InvalidArgumentException( - "Invalid stability for metric: $stability" + "Invalid stability for metric: $stability->name" ); } } - protected function checkType($type): void + protected function checkType(MetricType $type): void { if ( - $type !== self::TYPE_BOOL - && $type !== self::TYPE_COUNTER - && $type !== self::TYPE_GAUGE - && $type !== self::TYPE_TIMESTAMP - && $type !== self::TYPE_TEXT - && $type !== self::TYPE_COLLECTION + $type !== MetricType::BOOL + && $type !== MetricType::COUNTER + && $type !== MetricType::GAUGE + && $type !== MetricType::TIMESTAMP + && $type !== MetricType::TEXT + && $type !== MetricType::COLLECTION ) { throw new \InvalidArgumentException( - "Invalid type for metric: $type" + "Invalid type for metric: $type->name" ); } } @@ -130,19 +82,19 @@ protected function checkType($type): void protected function checkValue($type, $value): void { if ( - ($type === self::TYPE_BOOL && !is_bool($value)) - || ($type === self::TYPE_COUNTER && !is_int($value)) - || ($type === self::TYPE_GAUGE && !(is_int($value) || is_float($value))) - || ($type === self::TYPE_TIMESTAMP && !($value instanceof \DateTimeImmutable)) - || ($type === self::TYPE_TEXT && !is_string($value)) - || ($type === self::TYPE_COLLECTION && !is_array($value)) + ($type === MetricType::BOOL && !is_bool($value)) + || ($type === MetricType::COUNTER && !is_int($value)) + || ($type === MetricType::GAUGE && !(is_int($value) || is_float($value))) + || ($type === MetricType::TIMESTAMP && !($value instanceof \DateTimeImmutable)) + || ($type === MetricType::TEXT && !is_string($value)) + || ($type === MetricType::COLLECTION && !is_array($value)) ) { throw new \InvalidArgumentException( - "Invalid type " . gettype($value) . " for metric of type $type" + "Invalid type " . gettype($value) . " for metric of type $type->name" ); } - if ($type === self::TYPE_COLLECTION) { + if ($type === MetricType::COLLECTION) { foreach ($value as $v) { if (!($v instanceof Metric)) { throw new \InvalidArgumentException( @@ -153,12 +105,12 @@ protected function checkValue($type, $value): void } } - public function getStability(): string + public function getStability(): MetricStability { return $this->stability; } - public function getType(): string + public function getType(): MetricType { return $this->type; } @@ -168,6 +120,14 @@ public function getType(): string */ public function getValue() { + if (!is_null($this->value)) { + return $this->value; + } + + $value = $this->value_producer->__invoke(); + $this->checkValue($this->getType(), $value); + $this->value = $value; + return $this->value; } @@ -180,33 +140,33 @@ public function toYAML(int $indentation = 0): string { $value = $this->getValue(); switch ($this->getType()) { - case self::TYPE_BOOL: + case MetricType::BOOL: if ($value) { return "true"; } else { return "false"; } // no break - case self::TYPE_COUNTER: + case MetricType::COUNTER: return "$value"; - case self::TYPE_GAUGE: + case MetricType::GAUGE: if (is_int($value)) { return "$value"; } return sprintf("%.03f", $value); - case self::TYPE_TIMESTAMP: + case MetricType::TIMESTAMP: return $value->format(\DateTimeInterface::ISO8601); - case self::TYPE_TEXT: + case MetricType::TEXT: if (substr_count($value, "\n") > 0) { return ">" . str_replace("\n", "\n" . $this->getIndentation($indentation), "\n$value"); } return $value; - case self::TYPE_COLLECTION: + case MetricType::COLLECTION: return implode( "\n", array_map( function (string $k, Metric $v) use ($indentation): string { - if ($v->getType() === self::TYPE_COLLECTION) { + if ($v->getType() === MetricType::COLLECTION) { $split = "\n"; } else { $split = " "; @@ -218,7 +178,7 @@ function (string $k, Metric $v) use ($indentation): string { ) ); default: - throw new \LogicException("Unknown type: " . $this->getType()); + throw new \LogicException("Unknown type: " . $this->getType()->name); } } @@ -227,35 +187,35 @@ public function toArray(int $indentation = 0) $value = $this->getValue(); switch ($this->getType()) { - case self::TYPE_BOOL: + case MetricType::BOOL: if ($value) { return "true"; } else { return "false"; } // no break - case self::TYPE_COUNTER: + case MetricType::COUNTER: return (string) $value; - case self::TYPE_GAUGE: + case MetricType::GAUGE: if (is_int($value)) { return (string) $value; } return sprintf("%.03f", $value); - case self::TYPE_TIMESTAMP: + case MetricType::TIMESTAMP: return $value->format(\DateTimeInterface::ISO8601); - case self::TYPE_TEXT: + case MetricType::TEXT: if (substr_count($value, "\n") > 0) { return ">" . str_replace("\n", "\n" . $this->getIndentation($indentation), "\n$value"); } return $value; - case self::TYPE_COLLECTION: + case MetricType::COLLECTION: $result = []; foreach ($value as $key => $val) { $result[$key] = $val->toArray($indentation + 1); } return $result; default: - throw new \LogicException("Unknown type: " . $this->getType()); + throw new \LogicException("Unknown type: " . $this->getType()->name); } } @@ -274,16 +234,16 @@ protected function getIndentation(int $indentation = 0): string * * @return (Metric|null)[] */ - public function extractByStability(string $stability): array + public function extractByStability(MetricStability $stability): array { - if ($stability === self::STABILITY_MIXED) { + if ($stability === MetricStability::MIXED) { throw new \LogicException("Can not extract by mixed."); } if ($this->getStability() === $stability) { return [$this, null]; } - if ($this->getType() !== self::TYPE_COLLECTION) { + if ($this->getType() !== MetricType::COLLECTION) { return [null, $this]; } @@ -304,8 +264,8 @@ public function extractByStability(string $stability): array if ($extracted !== []) { $extracted = new Metric( $stability, - self::TYPE_COLLECTION, - $extracted, + MetricType::COLLECTION, + fn() => $extracted, $this->getDescription() ); } else { @@ -315,8 +275,8 @@ public function extractByStability(string $stability): array if ($rest !== []) { $rest = new Metric( $this->getStability(), - self::TYPE_COLLECTION, - $rest, + MetricType::COLLECTION, + fn() => $rest, $this->getDescription() ); } else { diff --git a/components/ILIAS/Setup/src/Metrics/MetricStability.php b/components/ILIAS/Setup/src/Metrics/MetricStability.php new file mode 100644 index 000000000000..93f5135db711 --- /dev/null +++ b/components/ILIAS/Setup/src/Metrics/MetricStability.php @@ -0,0 +1,38 @@ +store( $key, - new M(M::STABILITY_CONFIG, M::TYPE_BOOL, $value, $description) + new M(MS::CONFIG, MT::BOOL, $config_bool_callable, $description) ); } - public function storeConfigCounter(string $key, int $value, string $description = null): void + public function storeConfigCounter(string $key, callable $config_counter_callable, string $description = null): void { + if (!is_int($config_counter_callable())) { + throw new \InvalidArgumentException('Counter callable must return an integer'); + } $this->store( $key, - new M(M::STABILITY_CONFIG, M::TYPE_COUNTER, $value, $description) + new M(MS::CONFIG, MT::COUNTER, $config_counter_callable, $description) ); } - public function storeConfigGauge(string $key, $value, string $description = null): void + public function storeConfigGauge(string $key, callable $config_gauge_callable, string $description = null): void { + if (!is_int($config_gauge_callable()) && !is_double($config_gauge_callable)) { + throw new \InvalidArgumentException('Gauge callable must return an integer or double'); + } $this->store( $key, - new M(M::STABILITY_CONFIG, M::TYPE_GAUGE, $value, $description) + new M(MS::CONFIG, MT::GAUGE, $config_gauge_callable, $description) ); } - public function storeConfigTimestamp(string $key, \DateTimeImmutable $value, string $description = null): void + public function storeConfigTimestamp(string $key, callable $config_timestamp_callable, string $description = null): void { + if (get_class($config_timestamp_callable()) != \DateTimeImmutable::class) { + throw new \InvalidArgumentException('Timestamp callable must return a DateTimeImmutable'); + } $this->store( $key, - new M(M::STABILITY_CONFIG, M::TYPE_TIMESTAMP, $value, $description) + new M(MS::CONFIG, MT::TIMESTAMP, $config_timestamp_callable, $description) ); } - public function storeConfigText(string $key, string $value, string $description = null): void + public function storeConfigText(string $key, callable $config_text_callable, string $description = null): void { + if (!is_string($config_text_callable())) { + throw new \InvalidArgumentException('String callable must return a string'); + } $this->store( $key, - new M(M::STABILITY_CONFIG, M::TYPE_TEXT, $value, $description) + new M(MS::CONFIG, MT::TEXT, $config_text_callable, $description) ); } - public function storeStableBool(string $key, bool $value, string $description = null): void + public function storeStableBool(string $key, callable $stable_bool_callable, string $description = null): void { + if (!is_bool($stable_bool_callable())) { + throw new \InvalidArgumentException('Bool callable must return a boolean'); + } $this->store( $key, - new M(M::STABILITY_STABLE, M::TYPE_BOOL, $value, $description) + new M(MS::CONFIG, MT::BOOL, $stable_bool_callable, $description) ); } - public function storeStableCounter(string $key, int $value, string $description = null): void + public function storeStableCounter(string $key, callable $stable_counter_callable, string $description = null): void { + if (!is_int($stable_counter_callable())) { + throw new \InvalidArgumentException('Counter callable must return an integer'); + } $this->store( $key, - new M(M::STABILITY_STABLE, M::TYPE_COUNTER, $value, $description) + new M(MS::CONFIG, MT::COUNTER, $stable_counter_callable, $description) ); } - public function storeStableGauge(string $key, $value, string $description = null): void + public function storeStableGauge(string $key, callable $stable_gauge_callable, string $description = null): void { + if (!is_int($stable_gauge_callable()) && !is_double($stable_gauge_callable)) { + throw new \InvalidArgumentException('Gauge callable must return an integer or double'); + } $this->store( $key, - new M(M::STABILITY_STABLE, M::TYPE_GAUGE, $value, $description) + new M(MS::CONFIG, MT::GAUGE, $stable_gauge_callable, $description) ); } - public function storeStableTimestamp(string $key, \DateTimeImmutable $value, string $description = null): void + public function storeStableTimestamp(string $key, callable $stable_timestamp_callable, string $description = null): void { + if (get_class($stable_timestamp_callable()) != \DateTimeImmutable::class) { + throw new \InvalidArgumentException('Timestamp callable must return a DateTimeImmutable'); + } $this->store( $key, - new M(M::STABILITY_STABLE, M::TYPE_TIMESTAMP, $value, $description) + new M(MS::CONFIG, MT::TIMESTAMP, $stable_timestamp_callable, $description) ); } - public function storeStableText(string $key, string $value, string $description = null): void + public function storeStableText(string $key, callable $stable_text_callable, string $description = null): void { + if (!is_string($stable_text_callable())) { + throw new \InvalidArgumentException('String callable must return a string'); + } $this->store( $key, - new M(M::STABILITY_STABLE, M::TYPE_TEXT, $value, $description) + new M(MS::CONFIG, MT::TEXT, $stable_text_callable, $description) ); } - public function storeVolatileBool(string $key, bool $value, string $description = null): void + public function storeVolatileBool(string $key, callable $volatile_bool_callable, string $description = null): void { + if (!is_bool($volatile_bool_callable())) { + throw new \InvalidArgumentException('Bool callable must return a boolean'); + } $this->store( $key, - new M(M::STABILITY_VOLATILE, M::TYPE_BOOL, $value, $description) + new M(MS::CONFIG, MT::BOOL, $volatile_bool_callable, $description) ); } - public function storeVolatileCounter(string $key, int $value, string $description = null): void + public function storeVolatileCounter(string $key, callable $volatile_counter_callable, string $description = null): void { + if (!is_int($volatile_counter_callable())) { + throw new \InvalidArgumentException('Counter callable must return an integer'); + } $this->store( $key, - new M(M::STABILITY_VOLATILE, M::TYPE_COUNTER, $value, $description) + new M(MS::CONFIG, MT::COUNTER, $volatile_counter_callable, $description) ); } - public function storeVolatileGauge(string $key, $value, string $description = null): void + public function storeVolatileGauge(string $key, callable $volatile_gauge_callable, string $description = null): void { + if (!is_int($volatile_gauge_callable()) && !is_double($volatile_gauge_callable)) { + throw new \InvalidArgumentException('Gauge callable must return an integer or double'); + } $this->store( $key, - new M(M::STABILITY_VOLATILE, M::TYPE_GAUGE, $value, $description) + new M(MS::CONFIG, MT::GAUGE, $volatile_gauge_callable, $description) ); } - public function storeVolatileTimestamp(string $key, \DateTimeImmutable $value, string $description = null): void + public function storeVolatileTimestamp(string $key, callable $volatile_timestamp_callable, string $description = null): void { + if (get_class($volatile_timestamp_callable()) != \DateTimeImmutable::class) { + throw new \InvalidArgumentException('Timestamp callable must return a DateTimeImmutable'); + } $this->store( $key, - new M(M::STABILITY_VOLATILE, M::TYPE_TIMESTAMP, $value, $description) + new M(MS::CONFIG, MT::TIMESTAMP, $volatile_timestamp_callable, $description) ); } - public function storeVolatileText(string $key, string $value, string $description = null): void + public function storeVolatileText(string $key, callable $volatile_text_callable, string $description = null): void { + if (!is_string($volatile_text_callable())) { + throw new \InvalidArgumentException('String callable must return a string'); + } $this->store( $key, - new M(M::STABILITY_VOLATILE, M::TYPE_TEXT, $value, $description) + new M(MS::CONFIG, MT::TEXT, $volatile_text_callable, $description) ); } } diff --git a/components/ILIAS/Setup/tests/CLI/StatusCommandTest.php b/components/ILIAS/Setup/tests/CLI/StatusCommandTest.php index c48dca22ae20..10b88a06735f 100755 --- a/components/ILIAS/Setup/tests/CLI/StatusCommandTest.php +++ b/components/ILIAS/Setup/tests/CLI/StatusCommandTest.php @@ -1,7 +1,5 @@ filter($filter, $metric); + } +} class StatusCommandTest extends TestCase { @@ -36,7 +44,7 @@ public function testMetrics(): void $storage = new Metrics\ArrayStorage(); $objective = $this->createMock(Setup\Objective::class); $agent = $this->createMock(Setup\AgentCollection::class); - $expected = new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, []); + $expected = new M(MS::VOLATILE, MT::COLLECTION, fn() => []); $agent ->expects($this->once()) @@ -48,4 +56,129 @@ public function testMetrics(): void $this->assertEquals($expected, $result); } + + /** + * @dataProvider metricProvider + */ + public function testMetricsFilterWithEmptyFilter( + Metrics\Metric $metric, + Metrics\Metric $expected_metric, + string $filter, + bool $show_config_section, + bool $success + ): void { + $agent_finder = $this->createMock(Setup\AgentFinder::class); + $obj = new StatusCommandDummy($agent_finder); + + if (!$success) { + $this->expectException(\RuntimeException::class); + } + + $result = $obj->dummy_filter($filter, $metric); + + $this->assertEquals($show_config_section, $result[0]); + $this->assertEquals($expected_metric, $result[1]); + } + + public static function metricProvider(): array + { + return [ + "non_filter" => [ + new M(MS::VOLATILE, MT::COLLECTION, fn() => []), + new M(MS::VOLATILE, MT::COLLECTION, fn() => []), + "", + false, + true + ], + "non_collection_1" => [ + new M(MS::VOLATILE, MT::TEXT, fn() => "test"), + new M(MS::VOLATILE, MT::COLLECTION, fn() => []), + "test", + false, + false + ], + "non_collection_2" => [ + new M(MS::VOLATILE, MT::COUNTER, fn() => 2), + new M(MS::VOLATILE, MT::COLLECTION, fn() => []), + "test", + false, + false + ], + "non_collection_3" => [ + new M(MS::VOLATILE, MT::BOOL, fn() => false), + new M(MS::VOLATILE, MT::COLLECTION, fn() => []), + "test", + false, + false + ], + "non_collection_4" => [ + new M(MS::VOLATILE, MT::GAUGE, fn() => 3.14), + new M(MS::VOLATILE, MT::COLLECTION, fn() => []), + "test", + false, + false + ], + "non_collection_5" => [ + new M(MS::VOLATILE, MT::TIMESTAMP, fn() => new \DateTimeImmutable()), + new M(MS::VOLATILE, MT::COLLECTION, fn() => []), + "test", + false, + false + ], + "deep_1" => [ + new M(MS::VOLATILE, MT::COLLECTION, fn() => [ + "foo" => new M(MS::VOLATILE, MT::TEXT, fn() => "foo"), + "bar" => new M(MS::VOLATILE, MT::TEXT, fn() => "bar") + ]), + new M(MS::VOLATILE, MT::TEXT, fn() => "bar"), + "bar", + false, + true + ], + "deep_2" => [ + new M(MS::VOLATILE, MT::COLLECTION, fn() => [ + "foo" => new M(MS::VOLATILE, MT::COLLECTION, fn() => [ + "foobar" => new M(MS::VOLATILE, MT::TEXT, fn() => "foobar") + ]), + "bar" => new M(MS::VOLATILE, MT::TEXT, fn() => "bar") + ]), + new M(MS::VOLATILE, MT::TEXT, fn() => "bar"), + "foo.foobar", + false, + true + ], + "non_existing_key" => [ + new M(MS::VOLATILE, MT::COLLECTION, fn() => [ + "foo" => new M(MS::VOLATILE, MT::TEXT, fn() => "foo"), + "bar" => new M(MS::VOLATILE, MT::TEXT, fn() => "bar") + ]), + new M(MS::VOLATILE, MT::TEXT, fn() => "bar"), + "no_key", + false, + false + ], + "deep_config_1" => [ + new M(MS::VOLATILE, MT::COLLECTION, fn() => [ + "foo" => new M(MS::VOLATILE, MT::TEXT, fn() => "foo"), + "bar" => new M(MS::VOLATILE, MT::TEXT, fn() => "bar") + ]), + new M(MS::VOLATILE, MT::TEXT, fn() => "bar"), + "config.bar", + true, + true + ], + "deep_config_2" => [ + new M(MS::VOLATILE, MT::COLLECTION, fn() => [ + "foo" => new M(MS::VOLATILE, MT::COLLECTION, fn() => [ + "foobar" => new M(MS::VOLATILE, MT::TEXT, fn() => "foobar") + ]), + "bar" => new M(MS::VOLATILE, MT::TEXT, fn() => "bar") + ]), + new M(MS::VOLATILE, MT::TEXT, fn() => "bar"), + "config.foo.foobar", + true, + true + ], + ]; + } } diff --git a/components/ILIAS/Setup/tests/Metrics/ArrayStorageTest.php b/components/ILIAS/Setup/tests/Metrics/ArrayStorageTest.php index a08f0fcb0969..7e159eac2a42 100755 --- a/components/ILIAS/Setup/tests/Metrics/ArrayStorageTest.php +++ b/components/ILIAS/Setup/tests/Metrics/ArrayStorageTest.php @@ -1,7 +1,5 @@ true, "desc1"); + $m2 = new M(MS::CONFIG, MT::BOOL, fn() => true, "desc2"); $this->storage->store("m1", $m1); $this->storage->store("m2", $m2); @@ -51,8 +53,8 @@ public function testBasicStorage(): void public function testOverwrites(): void { - $m1 = new M(M::STABILITY_CONFIG, M::TYPE_BOOL, true, "desc1"); - $m2 = new M(M::STABILITY_CONFIG, M::TYPE_BOOL, true, "desc2"); + $m1 = new M(MS::CONFIG, MT::BOOL, fn() => true, "desc1"); + $m2 = new M(MS::CONFIG, MT::BOOL, fn() => true, "desc2"); $this->storage->store("m1", $m1); $this->storage->store("m1", $m2); @@ -66,7 +68,7 @@ public function testOverwrites(): void public function testNesting(): void { - $m1 = new M(M::STABILITY_CONFIG, M::TYPE_BOOL, true, "desc1"); + $m1 = new M(MS::CONFIG, MT::BOOL, fn() => true, "desc1"); $this->storage->store("a.b.c", $m1); @@ -83,16 +85,16 @@ public function testNesting(): void public function testAsMetric(): void { - $this->storage->store("a", new M(M::STABILITY_STABLE, M::TYPE_COUNTER, 0)); - $this->storage->store("b.c", new M(M::STABILITY_VOLATILE, M::TYPE_BOOL, true)); + $this->storage->store("a", new M(MS::STABLE, MT::COUNTER, fn() => 0)); + $this->storage->store("b.c", new M(MS::VOLATILE, MT::BOOL, fn() => true)); $expected = new M( - M::STABILITY_MIXED, - M::TYPE_COLLECTION, - [ - "a" => new M(M::STABILITY_STABLE, M::TYPE_COUNTER, 0), - "b" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [ - "c" => new M(M::STABILITY_VOLATILE, M::TYPE_BOOL, true) + MS::MIXED, + MT::COLLECTION, + fn() => [ + "a" => new M(MS::STABLE, MT::COUNTER, fn() => 0), + "b" => new M(MS::MIXED, MT::COLLECTION, fn() => [ + "c" => new M(MS::VOLATILE, MT::BOOL, fn() => true) ]) ] ); diff --git a/components/ILIAS/Setup/tests/Metrics/MetricTest.php b/components/ILIAS/Setup/tests/Metrics/MetricTest.php index 75f7d5974d5a..470e3387e4fd 100755 --- a/components/ILIAS/Setup/tests/Metrics/MetricTest.php +++ b/components/ILIAS/Setup/tests/Metrics/MetricTest.php @@ -1,7 +1,5 @@ expectException(\InvalidArgumentException::class); } - $metric = new Metrics\Metric($stability, $type, $value, $description); + $metric = new Metrics\Metric($stability, $type, fn() => $value, $description); $this->assertEquals($stability, $metric->getStability()); $this->assertEquals($type, $metric->getType()); $this->assertEquals($value, $metric->getValue()); @@ -48,24 +50,21 @@ public function testConstructMetric(string $stability, string $type, $value, str public static function metricProvider(): array { - $config = Metrics\Metric::STABILITY_CONFIG; - $stable = Metrics\Metric::STABILITY_STABLE; - $volatile = Metrics\Metric::STABILITY_VOLATILE; - $mixed = Metrics\Metric::STABILITY_MIXED; + $config = MS::CONFIG; + $stable = MS::STABLE; + $volatile = MS::STABLE; + $mixed = MS::MIXED; - $bool = Metrics\Metric::TYPE_BOOL; - $counter = Metrics\Metric::TYPE_COUNTER; - $gauge = Metrics\Metric::TYPE_GAUGE; - $timestamp = Metrics\Metric::TYPE_TIMESTAMP; - $text = Metrics\Metric::TYPE_TEXT; - $collection = Metrics\Metric::TYPE_COLLECTION; + $bool = MT::BOOL; + $counter = MT::COUNTER; + $gauge = MT::GAUGE; + $timestamp = MT::TIMESTAMP; + $text = MT::TEXT; + $collection = MT::COLLECTION; - $other_metric = new Metrics\Metric($volatile, $bool, true); + $other_metric = new Metrics\Metric($volatile, $bool, fn() => true); return [ - "invalid_stability" => ["no_stability", $bool, true, "", false], - "invalid_type" => [$config, "no_type", true, "", false], - "bool" => [$config, $bool, true, "A boolean", true], "counter" => [$stable, $counter, 23, "A counter", true], "gauge1" => [$volatile, $gauge, 42, "A gauge", true], @@ -126,37 +125,37 @@ public function testToYAML(M $metric, string $expected): void public static function typedMetricsProvider(): array { return [ - "bool_true" => [new M(M::STABILITY_STABLE, M::TYPE_BOOL, true), "true"], - "bool_false" => [new M(M::STABILITY_STABLE, M::TYPE_BOOL, false), "false"], - "counter_0" => [new M(M::STABILITY_STABLE, M::TYPE_COUNTER, 0), "0"], - "counter_1337" => [new M(M::STABILITY_STABLE, M::TYPE_COUNTER, 1337), "1337"], - "gauge_23" => [new M(M::STABILITY_STABLE, M::TYPE_GAUGE, 23), "23"], - "gauge_42_0" => [new M(M::STABILITY_STABLE, M::TYPE_GAUGE, 42.0), "42.000"], - "gauge_42_001" => [new M(M::STABILITY_STABLE, M::TYPE_GAUGE, 42.001), "42.001"], - "timestamp" => [new M(M::STABILITY_STABLE, M::TYPE_TIMESTAMP, new \DateTimeImmutable("1985-05-04T13:37:00+01:00")), "1985-05-04T13:37:00+0100"], - "text" => [new M(M::STABILITY_STABLE, M::TYPE_TEXT, "some text"), "some text"], - "text_with_nl" => [new M(M::STABILITY_STABLE, M::TYPE_TEXT, "some\ntext"), ">\nsome\ntext"], + "bool_true" => [new M(MS::STABLE, MT::BOOL, fn() => true), "true"], + "bool_false" => [new M(MS::STABLE, MT::BOOL, fn() => false), "false"], + "counter_0" => [new M(MS::STABLE, MT::COUNTER, fn() => 0), "0"], + "counter_1337" => [new M(MS::STABLE, MT::COUNTER, fn() => 1337), "1337"], + "gauge_23" => [new M(MS::STABLE, MT::GAUGE, fn() => 23), "23"], + "gauge_42_0" => [new M(MS::STABLE, MT::GAUGE, fn() => 42.0), "42.000"], + "gauge_42_001" => [new M(MS::STABLE, MT::GAUGE, fn() => 42.001), "42.001"], + "timestamp" => [new M(MS::STABLE, MT::TIMESTAMP, fn() => new \DateTimeImmutable("1985-05-04T13:37:00+01:00")), "1985-05-04T13:37:00+0100"], + "text" => [new M(MS::STABLE, MT::TEXT, fn() => "some text"), "some text"], + "text_with_nl" => [new M(MS::STABLE, MT::TEXT, fn() => "some\ntext"), ">\nsome\ntext"], ]; } public function testIndentation(): void { - $metrics = new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [ - "a" => new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [ - "h" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_h"), - "c" => new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [ - "d" => new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [ - "e" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_c_d_e"), - "f" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_c_d_f") + $metrics = new M(MS::STABLE, MT::COLLECTION, fn() => [ + "a" => new M(MS::STABLE, MT::COLLECTION, fn() => [ + "h" => new M(MS::STABLE, MT::TEXT, fn() => "a_h"), + "c" => new M(MS::STABLE, MT::COLLECTION, fn() => [ + "d" => new M(MS::STABLE, MT::COLLECTION, fn() => [ + "e" => new M(MS::STABLE, MT::TEXT, fn() => "a_c_d_e"), + "f" => new M(MS::STABLE, MT::TEXT, fn() => "a_c_d_f") ]), - "g" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_c_g") + "g" => new M(MS::STABLE, MT::TEXT, fn() => "a_c_g") ]), - "i" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_i\na_i") + "i" => new M(MS::STABLE, MT::TEXT, fn() => "a_i\na_i") ]), - "b" => new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [ - "j" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "b_j") + "b" => new M(MS::STABLE, MT::COLLECTION, fn() => [ + "j" => new M(MS::STABLE, MT::TEXT, fn() => "b_j") ]), - "k" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "k") + "k" => new M(MS::STABLE, MT::TEXT, fn() => "k") ]); $expected = << new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [ - "h" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "a_h"), - "c" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [ - "d" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [ - "e" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_c_d_e"), - "f" => new M(M::STABILITY_VOLATILE, M::TYPE_TEXT, "a_c_d_f") + $metrics = new M(MS::MIXED, MT::COLLECTION, fn() => [ + "a" => new M(MS::MIXED, MT::COLLECTION, fn() => [ + "h" => new M(MS::CONFIG, MT::TEXT, fn() => "a_h"), + "c" => new M(MS::MIXED, MT::COLLECTION, fn() => [ + "d" => new M(MS::MIXED, MT::COLLECTION, fn() => [ + "e" => new M(MS::STABLE, MT::TEXT, fn() => "a_c_d_e"), + "f" => new M(MS::VOLATILE, MT::TEXT, fn() => "a_c_d_f") ]), - "g" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "a_c_g") + "g" => new M(MS::CONFIG, MT::TEXT, fn() => "a_c_g") ]), - "i" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_i\na_i") + "i" => new M(MS::STABLE, MT::TEXT, fn() => "a_i\na_i") ]), - "b" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [ - "j" => new M(M::STABILITY_VOLATILE, M::TYPE_TEXT, "b_j") + "b" => new M(MS::MIXED, MT::COLLECTION, fn() => [ + "j" => new M(MS::VOLATILE, MT::TEXT, fn() => "b_j") ]), - "k" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "k") + "k" => new M(MS::CONFIG, MT::TEXT, fn() => "k") ]); - $expected_extracted = new M(M::STABILITY_CONFIG, M::TYPE_COLLECTION, [ - "a" => new M(M::STABILITY_CONFIG, M::TYPE_COLLECTION, [ - "h" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "a_h"), - "c" => new M(M::STABILITY_CONFIG, M::TYPE_COLLECTION, [ - "g" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "a_c_g") + $expected_extracted = new M(MS::CONFIG, MT::COLLECTION, fn() => [ + "a" => new M(MS::CONFIG, MT::COLLECTION, fn() => [ + "h" => new M(MS::CONFIG, MT::TEXT, fn() => "a_h"), + "c" => new M(MS::CONFIG, MT::COLLECTION, fn() => [ + "g" => new M(MS::CONFIG, MT::TEXT, fn() => "a_c_g") ]), ]), - "k" => new M(M::STABILITY_CONFIG, M::TYPE_TEXT, "k") + "k" => new M(MS::CONFIG, MT::TEXT, fn() => "k") ]); - $expected_rest = new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [ - "a" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [ - "c" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [ - "d" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [ - "e" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_c_d_e"), - "f" => new M(M::STABILITY_VOLATILE, M::TYPE_TEXT, "a_c_d_f") + $expected_rest = new M(MS::MIXED, MT::COLLECTION, fn() => [ + "a" => new M(MS::MIXED, MT::COLLECTION, fn() => [ + "c" => new M(MS::MIXED, MT::COLLECTION, fn() => [ + "d" => new M(MS::MIXED, MT::COLLECTION, fn() => [ + "e" => new M(MS::STABLE, MT::TEXT, fn() => "a_c_d_e"), + "f" => new M(MS::VOLATILE, MT::TEXT, fn() => "a_c_d_f") ]) ]), - "i" => new M(M::STABILITY_STABLE, M::TYPE_TEXT, "a_i\na_i") + "i" => new M(MS::STABLE, MT::TEXT, fn() => "a_i\na_i") ]), - "b" => new M(M::STABILITY_MIXED, M::TYPE_COLLECTION, [ - "j" => new M(M::STABILITY_VOLATILE, M::TYPE_TEXT, "b_j") + "b" => new M(MS::MIXED, MT::COLLECTION, fn() => [ + "j" => new M(MS::VOLATILE, MT::TEXT, fn() => "b_j") ]) ]); - list($extracted, $rest) = $metrics->extractByStability(M::STABILITY_CONFIG); + list($extracted, $rest) = $metrics->extractByStability(MS::CONFIG); $this->assertEquals($expected_extracted, $extracted); $this->assertEquals($expected_rest, $rest); @@ -238,8 +237,8 @@ public function testToArrayWithFlatValues(M $metric, string $expected): void public function testToArrayWithDeepOne(): void { - $metric = new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [ - "bool_true" => new M(M::STABILITY_STABLE, M::TYPE_BOOL, true) + $metric = new M(MS::STABLE, MT::COLLECTION, fn() => [ + "bool_true" => new M(MS::STABLE, MT::BOOL, fn() => true) ]); $this->assertEquals(["bool_true" => "true"], $metric->toArray()); @@ -247,9 +246,9 @@ public function testToArrayWithDeepOne(): void public function testToArrayWithDeepTwo(): void { - $metric = new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [ - "db" => new M(M::STABILITY_STABLE, M::TYPE_COLLECTION, [ - "bool_true" => new M(M::STABILITY_STABLE, M::TYPE_BOOL, true) + $metric = new M(MS::STABLE, MT::COLLECTION, fn() => [ + "db" => new M(MS::STABLE, MT::COLLECTION, fn() => [ + "bool_true" => new M(MS::STABLE, MT::BOOL, fn() => true) ]) ]); @@ -278,7 +277,7 @@ public function testToUIReport(): void ->willReturn($panel_f) ; - $metric = new M(M::STABILITY_STABLE, M::TYPE_TEXT, "string", ""); + $metric = new M(MS::STABLE, MT::TEXT, fn() => "string", ""); $result = $metric->toUIReport($factory, "Status"); diff --git a/components/ILIAS/Setup/tests/Metrics/StorageOnPathWrapperTest.php b/components/ILIAS/Setup/tests/Metrics/StorageOnPathWrapperTest.php index ad42dc917794..7ff9699f2a94 100755 --- a/components/ILIAS/Setup/tests/Metrics/StorageOnPathWrapperTest.php +++ b/components/ILIAS/Setup/tests/Metrics/StorageOnPathWrapperTest.php @@ -1,7 +1,5 @@ true, "desc"); $this->storage->expects($this->once()) ->method("store") diff --git a/components/ILIAS/Style/classes/Setup/class.ilStyleMetricsCollectedObjective.php b/components/ILIAS/Style/classes/Setup/class.ilStyleMetricsCollectedObjective.php index a868cc50ba39..047a89d47105 100755 --- a/components/ILIAS/Style/classes/Setup/class.ilStyleMetricsCollectedObjective.php +++ b/components/ILIAS/Style/classes/Setup/class.ilStyleMetricsCollectedObjective.php @@ -1,5 +1,21 @@ Extended GPL, see docs/LICENSE */ use ILIAS\Setup; @@ -22,12 +38,12 @@ public function collectFrom(Setup\Environment $environment, Setup\Metrics\Storag $storage->storeConfigBool( "manage_system_styles", - $ini->readVariable("tools", "enable_system_styles_management"), + fn() => $ini->readVariable("tools", "enable_system_styles_management"), "Can users manage system styles from within the installation?" ); $storage->storeConfigText( "path_to_scss", - $ini->readVariable("tools", "scss"), + fn() => $ini->readVariable("tools", "scss"), "The path to the binary that is used for compiling scss." ); } diff --git a/components/ILIAS/SystemFolder/classes/Setup/class.ilSystemFolderMetricsCollectedObjective.php b/components/ILIAS/SystemFolder/classes/Setup/class.ilSystemFolderMetricsCollectedObjective.php index fb468a5f2bc8..3fab67c8c0a1 100755 --- a/components/ILIAS/SystemFolder/classes/Setup/class.ilSystemFolderMetricsCollectedObjective.php +++ b/components/ILIAS/SystemFolder/classes/Setup/class.ilSystemFolderMetricsCollectedObjective.php @@ -1,5 +1,21 @@ Extended GPL, see docs/LICENSE */ use ILIAS\Setup; @@ -21,24 +37,24 @@ public function collectFrom(Setup\Environment $environment, Setup\Metrics\Storag } $settings = $factory->settingsFor("common"); $firstname = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings->get("admin_firstname", "") + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings->get("admin_firstname", "") ); $lastname = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings->get("admin_lastname", "") + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings->get("admin_lastname", "") ); $email = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_TEXT, - $settings->get("admin_email", "") + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::TEXT, + fn() => $settings->get("admin_email", "") ); $contact = new Setup\Metrics\Metric( - Setup\Metrics\Metric::STABILITY_CONFIG, - Setup\Metrics\Metric::TYPE_COLLECTION, - [ + Setup\Metrics\MetricStability::CONFIG, + Setup\Metrics\MetricType::COLLECTION, + fn() => [ "firstname" => $firstname, "lastname" => $lastname, "email" => $email diff --git a/components/ILIAS/Tree/classes/Setup/class.ilTreeMetricsCollectedObjective.php b/components/ILIAS/Tree/classes/Setup/class.ilTreeMetricsCollectedObjective.php index 0bf437065edb..0f37b351125d 100755 --- a/components/ILIAS/Tree/classes/Setup/class.ilTreeMetricsCollectedObjective.php +++ b/components/ILIAS/Tree/classes/Setup/class.ilTreeMetricsCollectedObjective.php @@ -1,7 +1,5 @@ storeConfigText( 'Tree Implementation', - $settings->get('main_tree_impl', 'ns') === 'ns' ? 'Nested Set' : 'Materialized Path', + fn() => $settings->get('main_tree_impl', 'ns') === 'ns' ? 'Nested Set' : 'Materialized Path', 'The database implementation of the ILIAS repository tree.' ); } diff --git a/components/ILIAS/Utilities/classes/Setup/class.ilUtilitiesMetricsCollectedObjective.php b/components/ILIAS/Utilities/classes/Setup/class.ilUtilitiesMetricsCollectedObjective.php index 70171bd903b4..061317d87e9b 100755 --- a/components/ILIAS/Utilities/classes/Setup/class.ilUtilitiesMetricsCollectedObjective.php +++ b/components/ILIAS/Utilities/classes/Setup/class.ilUtilitiesMetricsCollectedObjective.php @@ -1,7 +1,5 @@ storeConfigText( "path_to_convert", - $ini->readVariable("tools", "convert"), + fn() => $ini->readVariable("tools", "convert"), "The path to the binary from imagemagick that is used to convert images." ); $storage->storeConfigText( "path_to_zip", - $ini->readVariable("tools", "zip"), + fn() => $ini->readVariable("tools", "zip"), "The path to the binary that is used for zipping files." ); $storage->storeConfigText( "path_to_unzip", - $ini->readVariable("tools", "unzip"), + fn() => $ini->readVariable("tools", "unzip"), "The path to the binary that is used for unzipping files." ); } diff --git a/components/ILIAS/VirusScanner_/classes/Setup/class.ilVirusScannerMetricsCollectedObjective.php b/components/ILIAS/VirusScanner_/classes/Setup/class.ilVirusScannerMetricsCollectedObjective.php index 73b7bd40fb59..ce58418a8fcc 100755 --- a/components/ILIAS/VirusScanner_/classes/Setup/class.ilVirusScannerMetricsCollectedObjective.php +++ b/components/ILIAS/VirusScanner_/classes/Setup/class.ilVirusScannerMetricsCollectedObjective.php @@ -1,7 +1,5 @@ readVariable("tools", "vscantype"); $storage->storeConfigText( "virusscanner", - $virus_scanner, + fn() => $virus_scanner, "The engine that is used for virus scanning." ); if ($virus_scanner === ilVirusScannerSetupConfig::VIRUS_SCANNER_ICAP) { $storage->storeConfigText( "icap_client_path", - $ini->readVariable("tools", "icap_client_path"), + fn() => $ini->readVariable("tools", "icap_client_path"), "The configured ICAP client path." ); $storage->storeConfigText( "icap_host", - $ini->readVariable("tools", "icap_host"), + fn() => $ini->readVariable("tools", "icap_host"), "The configured ICAP host." ); $storage->storeConfigText( "icap_port", - $ini->readVariable("tools", "icap_port"), + fn() => $ini->readVariable("tools", "icap_port"), "The configured ICAP port." ); $storage->storeConfigText( "icap_service_name", - $ini->readVariable("tools", "icap_service_name"), + fn() => $ini->readVariable("tools", "icap_service_name"), "The configured ICAP service name." ); } elseif (is_string($virus_scanner) && @@ -72,12 +72,12 @@ protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Sto $virus_scanner !== ilVirusScannerSetupConfig::VIRUS_SCANNER_NONE) { $storage->storeConfigText( "path_to_scan", - $ini->readVariable("tools", "scancommand"), + fn() => $ini->readVariable("tools", "scancommand"), "The path to the binary that is used for virus scanning." ); $storage->storeConfigText( "path_to_clean", - $ini->readVariable("tools", "cleancommand"), + fn() => $ini->readVariable("tools", "cleancommand"), "The path to the binary that is used for cleaning up after virus scanning." ); } diff --git a/components/ILIAS/setup_/README.md b/components/ILIAS/setup_/README.md index 1ece4390cc63..68298fa7a65f 100755 --- a/components/ILIAS/setup_/README.md +++ b/components/ILIAS/setup_/README.md @@ -98,6 +98,9 @@ system where ILIAS was not installed, for example, the output only contains the information that ilias is not installed. The command also reports on the configuration of the installation. +Use the -f option to pass filtering options to the command. The command could then look like this: +`php setup/setup.php status -f config.common`. Here only the common section under config would be output. + The output of the command is formatted as YAML to be easily readable by people and machines. So we encourage you to use this command for monitoring your system and also request status information via our feature process that you are interested in. diff --git a/components/ILIAS/setup_/classes/class.ilSetupMetricsCollectedObjective.php b/components/ILIAS/setup_/classes/class.ilSetupMetricsCollectedObjective.php index b4bacc1cf770..22bc0fabba08 100755 --- a/components/ILIAS/setup_/classes/class.ilSetupMetricsCollectedObjective.php +++ b/components/ILIAS/setup_/classes/class.ilSetupMetricsCollectedObjective.php @@ -1,7 +1,5 @@ getResource(Setup\Environment::RESOURCE_CLIENT_INI); $storage->storeStableBool( "is_installed", - $ini !== null && $client_ini !== null, + fn() => $ini !== null && $client_ini !== null, "Are there any indications an installation was performed?" ); $client_id = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_ID); if ($client_id) { $storage->storeConfigText( "client_id", - $client_id, + fn() => $client_id, "Id of the ILIAS client." ); } - $settings_factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY); + $settings_factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY); if ($settings_factory) { $common_settings = $settings_factory->settingsFor("common"); $nic_enabled = $common_settings->get("nic_enabled") == "1"; $storage->storeStableBool( "nic_enabled", - $nic_enabled, + fn() => $nic_enabled, "Is the installation registered at the ILIAS NIC server?" ); if ($nic_enabled) { $storage->storeConfigText( "inst_id", - $common_settings->get("inst_id"), + fn() => $common_settings->get("inst_id"), "The id of the installation as provided by the ILIAS NIC server." ); }