Index: branches/5.1.x/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -N -r13086 -r13113 --- branches/5.1.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 13086) +++ branches/5.1.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 13113) @@ -1,6 +1,6 @@ _directorySeparator = preg_quote( DIRECTORY_SEPARATOR ); - $this->_skipFolders[] = trim(WRITEBALE_BASE, '/'); // system folder (where web server can write) + $this->_directorySeparator = preg_quote(DIRECTORY_SEPARATOR); $editor_path = explode('/', trim(EDITOR_PATH, '/')); $this->_skipFolders[] = array_pop($editor_path); // last of cmseditor folders + + $this->_moduleFolderRegExp = '#' . $this->_directorySeparator . '(core|modules' . $this->_directorySeparator . '.*?)' . $this->_directorySeparator . '#'; } function CacheParsedData() @@ -95,24 +103,24 @@ } $cache = Array( - 'Factory.Files' => $this->Application->Factory->Files, - 'Factory.realClasses' => $this->Application->Factory->realClasses, - 'Factory.Dependencies' => $this->Application->Factory->Dependencies, - 'ConfigReader.prefixFiles' => $this->prefixFiles, - 'EventManager.buildEvents' => $event_manager->buildEvents, - 'EventManager.beforeRegularEvents' => $event_manager->beforeRegularEvents, - 'EventManager.afterRegularEvents' => $event_manager->afterRegularEvents, - 'EventManager.beforeHooks' => $event_manager->beforeHooks, - 'EventManager.afterHooks' => $event_manager->afterHooks, - 'TagsAggregator.data' => $aggregator->_Array, + 'Factory.Files' => $this->Application->Factory->Files, + 'Factory.realClasses' => $this->Application->Factory->realClasses, + 'Factory.Dependencies' => $this->Application->Factory->Dependencies, + 'ConfigReader.prefixFiles' => $this->prefixFiles, + 'EventManager.buildEvents' => $event_manager->buildEvents, + 'EventManager.beforeRegularEvents' => $event_manager->beforeRegularEvents, + 'EventManager.afterRegularEvents' => $event_manager->afterRegularEvents, + 'EventManager.beforeHooks' => $event_manager->beforeHooks, + 'EventManager.afterHooks' => $event_manager->afterHooks, + 'TagsAggregator.data' => $aggregator->_Array, - // the following caches should be reset based on admin interaction (adjusting config, enabling modules etc) - 'Application.Caches.ConfigVariables' => $this->Application->Caches['ConfigVariables'], - 'Application.ConfigCacheIds' => $this->Application->ConfigCacheIds, - 'Application.ConfigHash' => $this->Application->ConfigHash, - 'Application.ReplacementTemplates' => $this->Application->ReplacementTemplates, - 'Application.RewriteListeners' => $this->Application->RewriteListeners, - 'Application.ModuleInfo' => $this->Application->ModuleInfo, + // the following caches should be reset based on admin interaction (adjusting config, enabling modules etc) + 'Application.Caches.ConfigVariables' => $this->Application->Caches['ConfigVariables'], + 'Application.ConfigCacheIds' => $this->Application->ConfigCacheIds, + 'Application.ConfigHash' => $this->Application->ConfigHash, + 'Application.ReplacementTemplates' => $this->Application->ReplacementTemplates, + 'Application.RewriteListeners' => $this->Application->RewriteListeners, + 'Application.ModuleInfo' => $this->Application->ModuleInfo, ); $conn =& $this->Application->GetADODBConnection(); @@ -275,7 +283,8 @@ shuffle($this->configFiles); } else { - $this->findConfigFiles($folderPath); // search from base directory + $this->findConfigFiles(FULL_PATH . '/core'); // search from core directory + $this->findConfigFiles($folderPath); // search from modules directory } foreach ($this->configFiles as $filename) @@ -743,7 +752,7 @@ function PreloadConfigFile($filename) { - $config_found = file_exists(FULL_PATH.$filename) && $this->configAllowed($filename); + $config_found = file_exists(FULL_PATH . $filename) && $this->configAllowed($filename); if (defined('DEBUG_MODE') && DEBUG_MODE && defined('DBG_PROFILE_INCLUDES') && DBG_PROFILE_INCLUDES) { if ( in_array($filename, get_required_files()) ) { @@ -771,7 +780,7 @@ // config file is included for 1st time -> save it's content for future processing $prefix = array_key_exists('Prefix', $config) ? $config['Prefix'] : ''; - preg_match('#' . $this->_directorySeparator . '(.*)' . $this->_directorySeparator . '#U', $filename, $rets); + preg_match($this->_moduleFolderRegExp, $filename, $rets); $config['ModuleFolder'] = $rets[1]; $config['BasePath'] = dirname(FULL_PATH . $filename); @@ -928,33 +937,36 @@ */ function configAllowed($config_path) { + static $module_paths = null; + if (defined('IS_INSTALL') && IS_INSTALL) { // at installation start no modules in db and kernel configs could not be read return true; } - if (preg_match('#' . $this->_directorySeparator . 'plugins' . $this->_directorySeparator . '|' . $this->_directorySeparator . 'core#', $config_path)) { - // always allow to include configs from core and plugins folder + if (preg_match('#^' . $this->_directorySeparator . 'core#', $config_path)) { + // always allow to include configs from "core" module's folder return true; } - $module_found = false; if (!$this->Application->ModuleInfo) { return false; } - foreach ($this->Application->ModuleInfo as $module_name => $module_info) { - $module_path = DIRECTORY_SEPARATOR . trim($module_info['Path'], '/') . DIRECTORY_SEPARATOR; + if (!isset($module_paths)) { + $module_paths = Array (); - // config file path starts with module folder path - if (substr($config_path, 0, strlen($module_path)) == $module_path) { -// if (preg_match('#^' . preg_quote($module_path, '/') . '#', $config_path)) { - $module_found = true; - break; + foreach ($this->Application->ModuleInfo as $module_name => $module_info) { + $module_paths[] = rtrim($module_info['Path'], '/'); } + + $module_paths = array_unique($module_paths); } - return $module_found; + preg_match($this->_moduleFolderRegExp, $config_path, $rets); + + // config file path starts with module folder path + return in_array($rets[1], $module_paths); } /**