Index: branches/5.1.x/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -N -r13492 -r13545 --- branches/5.1.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 13492) +++ branches/5.1.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 13545) @@ -1,6 +1,6 @@ ProcessAllConfigs) return ; $this->FinalStage = true; foreach ($this->configData as $prefix => $config) { - if (in_array($prefix, $this->AfterConfigProcessed)) { - continue; - } - - $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') ); - $this->AfterConfigProcessed[] = $prefix; + $this->runAfterConfigRead($prefix); } if (!isset($store_cache)) { @@ -410,7 +405,7 @@ } // process prioritized listeners - asort($prioritized_listeners); + asort($prioritized_listeners, SORT_NUMERIC); foreach ($prioritized_listeners as $prefix => $priority) { $listeners[$prefix] = $this->Application->RewriteListeners[$prefix]; } @@ -439,6 +434,7 @@ // parse all configs $this->ProcessAllConfigs = true; + $this->AfterConfigProcessed = Array (); $this->includeConfigFiles(MODULES_PATH, false); $this->ParseConfigs(); $this->AfterConfigRead(false); @@ -463,12 +459,7 @@ // call OnAfterConfigRead for cloned configs $new_clones = array_unique($new_clones); foreach ($new_clones as $prefix) { - if (in_array($prefix, $this->AfterConfigProcessed)) { - continue; - } - - $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') ); - $this->AfterConfigProcessed[] = $prefix; + $this->runAfterConfigRead($prefix); } } @@ -852,18 +843,37 @@ $file = $this->prefixFiles[$prefix]; $prefix = $this->PreloadConfigFile($file); + if ($this->FinalStage) { + // run prefix OnAfterConfigRead so all + // hooks to it can define their clonses + $this->runAfterConfigRead($prefix); + } + $clones = $this->postProcessConfig($prefix, 'AggregateConfigs', 'sub_prefix'); $clones = array_merge($this->postProcessConfig($prefix, 'Clones', 'prefix'), $clones); if ($this->FinalStage) { - array_unshift($clones, $prefix); $clones = array_unique($clones); foreach ($clones as $a_prefix) { - $this->Application->HandleEvent( new kEvent($a_prefix.':OnAfterConfigRead') ); + $this->runAfterConfigRead($a_prefix); } } } + function runAfterConfigRead($prefix) + { + if (in_array($prefix, $this->AfterConfigProcessed)) { + return ; + } + + $this->Application->HandleEvent( new kEvent($prefix . ':OnAfterConfigRead') ); + + if (!(defined('IS_INSTALL') && IS_INSTALL)) { + // allow to call OnAfterConfigRead multiple times during install + array_push($this->AfterConfigProcessed, $prefix); + } + } + /** * Reads unit (specified by $prefix) * option specified by $option