CLISetup/Fixup

* also convert Cfg test function, forgotten in 2386e35207
This commit is contained in:
Sarjuuk
2024-06-30 16:54:02 +02:00
parent 2386e35207
commit 8016802ec6
2 changed files with 20 additions and 19 deletions

View File

@@ -212,7 +212,7 @@ class Cfg
{ {
$errMsg = ''; $errMsg = '';
if (!method_exists('Cfg', $key)) 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 else
self::{$key}($value, $errMsg); self::{$key}($value, $errMsg);
@@ -387,12 +387,8 @@ class Cfg
if (!CLI) if (!CLI)
return true; return true;
CLISetup::$localeIds = []; // note: Change is written to db and storage at this point, but can be rolled back.
foreach (CLISetup::$locales as $idx => $_) if (CLISetup::setLocales())
if (!($value) || ($value & (1 << $idx)))
CLISetup::$localeIds[] = $idx;
if (!empty(CLISetup::$localeIds))
return true; return true;
$msg .= 'no valid locales set'; $msg .= 'no valid locales set';

View File

@@ -170,18 +170,8 @@ class CLISetup
yield $name => [$src, $ref]; 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 // optional limit handled locales
if (isset(self::$opts['locales'])) if (isset(self::$opts['locales']))
{ {
@@ -201,7 +191,22 @@ class CLISetup
if (($l = Cfg::get('LOCALES')) && !($l & (1 << $idx))) if (($l = Cfg::get('LOCALES')) && !($l & (1 << $idx)))
unset(self::$locales[$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); CLI::write('No valid locale specified. Check your config or --locales parameter, if used', CLI::LOG_ERROR);
// get site status // get site status