Index: branches/unlabeled/unlabeled-1.76.2/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -N -r8340 -r8663 --- branches/unlabeled/unlabeled-1.76.2/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 8340) +++ branches/unlabeled/unlabeled-1.76.2/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 8663) @@ -219,12 +219,12 @@ $clones = $this->postProcessConfig($prefix, 'Clones', 'prefix'); } - // 2. process prioritized configs and their dependencies + // 2. process prioritized configs and their dependencies asort($prioritized_configs); foreach ($prioritized_configs as $prefix => $priority) { $this->parseConfig($prefix); } - + foreach ($prioritized_configs as $prefix => $priority) { $this->ProcessDependencies($prefix); } @@ -239,11 +239,11 @@ $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') ); $this->AfterConfigProcessed[] = $prefix; } - + if ($this->StoreCache) { $this->processDynamicClones(); $this->CacheParsedData(); - + if ($this->Application->isDebugMode(false) && constOn('DBG_VALIDATE_CONFIGS')) { // validate configs here to have changes from OnAfterConfigRead hooks to prefixes foreach ($this->configData as $prefix => $config) { @@ -260,12 +260,27 @@ */ function ReReadConfigs() { - $this->includeConfigFiles(MODULES_PATH); + // clear restored cache (not in db) + $this->Application->Factory->Files = Array (); + $this->Application->Factory->realClasses = Array (); + $this->Application->Factory->Dependencies = Array (); + + $this->Application->EventManager->beforeRegularEvents = Array (); + $this->Application->EventManager->afterRegularEvents = Array (); + $this->Application->EventManager->beforeHooks = Array (); + $this->Application->EventManager->afterHooks = Array (); + + // otherwise ModulesHelper indirectly used from includeConfigFiles won't work + $this->Application->RegisterDefaultClasses(); + + // parse all configs + $this->ProcessAllConfigs = true; + $this->includeConfigFiles(MODULES_PATH, false); $this->ParseConfigs(); $this->AfterConfigRead(); $this->processDynamicClones(); } - + /** * Process clones, that were defined via OnAfterConfigRead event * @@ -279,7 +294,7 @@ $new_clones = array_merge($new_clones, $clones); } } - + // call OnAfterConfigRead for cloned configs $new_clones = array_unique($new_clones); foreach ($new_clones as $prefix) { @@ -288,7 +303,7 @@ $this->AfterConfigProcessed[] = $prefix; } } - + /** * Register nessasary classes * This method should only process the data which is cached! @@ -407,21 +422,21 @@ function ValidateConfig($prefix) { global $debugger; - + $config =& $this->configData[$prefix]; - + $tablename = $config['TableName']; $float_types = Array ('float', 'double', 'numeric'); $conn =& $this->Application->GetADODBConnection(); - + $table_found = $conn->Query('SHOW TABLES LIKE "'.$tablename.'"'); if (!$table_found) { // config present, but table missing, strange $debugger->appendHTML("Config Warning: Table $tablename missing, but prefix ".$config['Prefix']." requires it!"); safeDefine('DBG_RAISE_ON_WARNINGS', 1); return ; } - + $res = $conn->Query('DESCRIBE '.$tablename); $config_link = $debugger->getFileLink(FULL_PATH.$this->prefixFiles[$config['Prefix']], 1, $config['Prefix']); @@ -434,34 +449,34 @@ 'invalid_default' => 'Default value for field %s%s not sync. to db (in config = %s, in db = %s)', 'type_missing' => 'Type definition for field %s missing in config', ); - + $config_errors = Array (); $tablename = preg_replace('/^'.preg_quote(TABLE_PREFIX, '/').'(.*)/', '\\1', $tablename); // remove table prefix foreach ($res as $field) { $f_name = $field['Field']; - + if (getArrayValue($config, 'Fields')) { if (preg_match('/l[\d]+_[\w]/', $f_name)) { // skip multilingual fields continue; } - + if (!array_key_exists ($f_name, $config['Fields'])) { $config_errors[] = sprintf($error_messages['field_not_found'], $f_name); } else { if (is_numeric($field['Default'])) { $field['Default'] = preg_match('/[\.,]/', $field['Default']) ? (float)$field['Default'] : (int)$field['Default']; } - + $options = $config['Fields'][$f_name]; $default_missing = false; if (!array_key_exists('default', $options)) { $config_errors[] = sprintf($error_messages['default_missing'], $f_name); $default_missing = true; } - + if ($field['Null'] != 'YES') { // field is NOT NULL in database (MySQL5 for null returns "NO", but MySQL4 returns "") if ( $f_name != $config['IDField'] && !isset($options['not_null']) && !isset($options['required']) ) { @@ -474,13 +489,13 @@ else { if (isset($options['not_null']) && $options['not_null']) { $config_errors[] = sprintf($error_messages['not_null_error3'], $f_name); - } + } } if (!array_key_exists('type', $options)) { $config_errors[] = sprintf($error_messages['type_missing'], $f_name); } - + if (!$default_missing) { if ($f_name == $config['IDField'] && $options['type'] != 'string' && $options['default'] !== 0) { $config_errors[] = sprintf($error_messages['invalid_default'], 'IDField ', $f_name, $this->varDump($options['default']), $this->varDump($field['Default'])); @@ -492,16 +507,16 @@ } } } - + if ($config_errors) { $error_prefix = 'Config Error'.(count($config_errors) > 1 ? 's' : '').': for prefix '.$config_link.' ('.$tablename.') in unit config:
'; $config_errors = $error_prefix.'   '.implode('
   ', $config_errors); - + $debugger->appendHTML($config_errors); safeDefine('DBG_RAISE_ON_WARNINGS', 1); } } - + function varDump($value) { return ''.var_export($value, true).' of '.gettype($value); @@ -785,12 +800,12 @@ { return isset($this->prefixFiles[$prefix]) ? true : false; } - + function iterateConfigs($callback_function, $params) { $this->includeConfigFiles(MODULES_PATH); //make sure to re-read all configs $this->AfterConfigRead(); - + foreach ($this->configData as $prefix => $config_data) { $callback_function[0]->$callback_function[1]($prefix, $config_data, $params); }