Adding check_junk optional support during normalization
Publish PHP Package / docker (push) Successful in 7s Details

This commit is contained in:
Pavel Shevaev 2025-02-25 15:41:22 +03:00
parent aa9ff115aa
commit 742e6692d5
2 changed files with 11 additions and 5 deletions

View File

@ -154,6 +154,7 @@ class ConfigFetchParams
public bool $verbose = false;
public ?int $max_workers = null;
public bool $touch_files_with_includes = true;
public bool $check_junk = false;
function __construct(ConfigGlobals $globals, ConfigScanResult $scanned,
bool $force_stale = false, bool $verbose = false, ?int $max_workers = null)
@ -350,7 +351,9 @@ function _config_merge_fetch_results(ConfigFetchParams $params, array $results_b
return $result;
}
function _config_invalidate_cache(ConfigFetchParams $params, string $base_dir, string $file, string $cache_file, ?int &$parser_type = null) : ConfigCacheEntry
function _config_invalidate_cache(
ConfigFetchParams $params, string $base_dir, string $file,
string $cache_file, ?int &$parser_type = null) : ConfigCacheEntry
{
list($conf_id, $conf_strid) = config_ensure_header($base_dir, $file);
if(!$conf_id)
@ -363,14 +366,15 @@ function _config_invalidate_cache(ConfigFetchParams $params, string $base_dir, s
$pres = config_parse($params->globals->base_dirs, $file);
if($pres->error !== 0)
throw new Exception("Error({$pres->error}) while parsing {$file}:\n" . $pres->error_descr);
throw new Exception("Parse error({$pres->error}):\n" . $pres->error_descr);
$parser_type = $pres->parser_type;
$parsed_arr = $pres->parsed_arr;
//TODO: these hardcoded keys below probably shouldn't be part of data?
$parsed_arr['id'] = $conf_id;
$parsed_arr['strid'] = $conf_strid;
list($class, $class_id, $normalized_data) = config_apply_class_normalization($parsed_arr);
list($class, $class_id, $normalized_data)
= config_apply_class_normalization($parsed_arr, $params->check_junk);
$cache_payload_file = config_get_cache_payload_path($params->globals, $file);

View File

@ -143,11 +143,13 @@ function config_ensure_header(string $conf_dir, string $file, bool $force = fals
}
}
function config_apply_class_normalization(array $kv_data) : array
function config_apply_class_normalization(array $kv_data, bool $check_junk = false) : array
{
$class = $kv_data['class'];
$norm_data = array();
call_user_func_array([$class, 'normalize'], array(&$kv_data, &$norm_data));
unset($kv_data['class']);
call_user_func_array([$class, 'normalize'],
array(&$kv_data, &$norm_data, true, $check_junk));
return array($class, $class::CLASS_ID, $norm_data);
}