From 8016802ec6a8a75d58eab14a208fbaee5ef3cb38 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sun, 30 Jun 2024 16:54:02 +0200 Subject: [PATCH] CLISetup/Fixup * also convert Cfg test function, forgotten in 2386e352075414073dba65ae98644640cb7b084b --- includes/config.class.php | 10 +++------- setup/tools/CLISetup.class.php | 29 +++++++++++++++++------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/includes/config.class.php b/includes/config.class.php index 95b872b7..52e65d1b 100644 --- a/includes/config.class.php +++ b/includes/config.class.php @@ -212,7 +212,7 @@ class Cfg { $errMsg = ''; if (!method_exists('Cfg', $key)) - $errMsg = 'required onSetFN validator not set'; + $errMsg = 'Aowow config '.strtoupper($key).' flagged for onSetFN validation, but no handler was set'; else self::{$key}($value, $errMsg); @@ -387,12 +387,8 @@ class Cfg if (!CLI) return true; - CLISetup::$localeIds = []; - foreach (CLISetup::$locales as $idx => $_) - if (!($value) || ($value & (1 << $idx))) - CLISetup::$localeIds[] = $idx; - - if (!empty(CLISetup::$localeIds)) + // note: Change is written to db and storage at this point, but can be rolled back. + if (CLISetup::setLocales()) return true; $msg .= 'no valid locales set'; diff --git a/setup/tools/CLISetup.class.php b/setup/tools/CLISetup.class.php index 4c4b5884..35167219 100644 --- a/setup/tools/CLISetup.class.php +++ b/setup/tools/CLISetup.class.php @@ -170,18 +170,8 @@ class CLISetup yield $name => [$src, $ref]; } - public static function init() : void + public static function setLocales() : bool { - self::evalOpts(); - - // optional logging - if (isset(self::$opts['log'])) - CLI::initLogFile(trim(self::$opts['log'])); - - // alternative data source (no quotes, use forward slash) - if (isset(self::$opts['datasrc'])) - self::$srcDir = CLI::nicePath(self::$opts['datasrc']); - // optional limit handled locales if (isset(self::$opts['locales'])) { @@ -201,7 +191,22 @@ class CLISetup if (($l = Cfg::get('LOCALES')) && !($l & (1 << $idx))) unset(self::$locales[$idx]); - if (!self::$locales) + return !!self::$locales; + } + + public static function init() : void + { + self::evalOpts(); + + // optional logging + if (isset(self::$opts['log'])) + CLI::initLogFile(trim(self::$opts['log'])); + + // alternative data source (no quotes, use forward slash) + if (isset(self::$opts['datasrc'])) + self::$srcDir = CLI::nicePath(self::$opts['datasrc']); + + if (!self::setLocales()) CLI::write('No valid locale specified. Check your config or --locales parameter, if used', CLI::LOG_ERROR); // get site status