Index: branches/5.2.x/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -N -r14095 -r14184 --- branches/5.2.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 14095) +++ branches/5.2.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 14184) @@ -1,6 +1,6 @@ Application->recallObject('TagsAggregator', 'kArray'); - /* @var $aggregator kArray */ - - $this->preloadConfigVars(); // preloading will put to cache - - $cache = array_merge( - $this->Application->Factory->getToCache(), - $this->getToCache(), - $this->Application->EventManager->getToCache(), - $aggregator->getToCache(), - $this->Application->getToCache() - ); - - if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { - $this->Application->setCache('master:configs_parsed', serialize($cache)); - $this->Application->setCache('master:config_files', serialize($this->configFiles)); - } - else { - $this->Application->setDBCache('configs_parsed', serialize($cache)); - $this->Application->setDBCache('config_files', serialize($this->configFiles)); - } - - $cache_rebuild_by = SERVER_NAME . ' (' . getenv('REMOTE_ADDR') . ') - ' . adodb_date('d/m/Y H:i:s'); - $this->Application->setDBCache('last_cache_rebuild', $cache_rebuild_by); - - unset($this->configFiles); - } - - function preloadConfigVars() - { - $config_vars = Array ( - // session related - 'SessionTimeout', - 'SessionCookieName', - 'SessionCookieDomains', - 'SessionBrowserSignatureCheck', - 'SessionIPAddressCheck', - 'CookieSessions', - 'KeepSessionOnBrowserClose', - 'User_GuestGroup', - 'User_LoggedInGroup', - - // output related - 'UseModRewrite', - 'UseContentLanguageNegotiation', - 'UseOutputCompression', - 'OutputCompressionLevel', - 'Config_Site_Time', - 'SystemTagCache', - - // tracking related - 'UseChangeLog', - 'UseVisitorTracking', - 'ModRewriteUrlEnding', - 'ForceModRewriteUrlEnding', - 'UseCronForRegularEvent', - ); - - foreach ($config_vars as $var) { - $this->Application->ConfigValue($var); - } - } - - function RestoreParsedData() - { - if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { - $data = $this->Application->getCache('master:configs_parsed', false); - } - else { - $data = $this->Application->getDBCache('configs_parsed'); - } - - if ($data) { - $cache = unserialize($data); // 126 KB all modules - unset($data); - - $this->Application->Factory->setFromCache($cache); - $this->setFromCache($cache); - $this->Application->EventManager->setFromCache($cache); - - $aggregator =& $this->Application->recallObject('TagsAggregator', 'kArray'); - /* @var $aggregator kArray */ - - $aggregator->setFromCache($cache); - $this->Application->setFromCache($cache); - unset($cache); - - return true; - - } - - return false; - } - - function ResetParsedData($include_sections = false) - { - if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { - $this->Application->deleteCache('master:configs_parsed'); - } - else { - $this->Application->deleteDBCache('configs_parsed'); - } - - if ($include_sections) { - if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { - $this->Application->deleteCache('master:sections_parsed'); - } - else { - $this->Application->deleteDBCache('sections_parsed'); - } - } - } - function scanModules($folderPath, $cache = true) { if (defined('IS_INSTALL') && IS_INSTALL && !defined('FORCE_CONFIG_CACHE')) { @@ -218,7 +103,8 @@ } if ($cache) { - $restored = $this->RestoreParsedData(); + $restored = $this->Application->cacheManager->LoadUnitCache(); + if ($restored) { if ( defined('DEBUG_MODE') && DEBUG_MODE && $this->Application->isDebugMode() ) { $this->Application->Debugger->appendHTML('UnitConfigReader: Restoring Cache'); @@ -292,7 +178,7 @@ $data = $this->Application->getDBCache('config_files'); } - if ($cache && $data) { + if ($data) { $this->configFiles = unserialize($data); if ( !defined('DBG_VALIDATE_CONFIGS') && !DBG_VALIDATE_CONFIGS ) { @@ -302,6 +188,15 @@ else { $this->findConfigFiles(FULL_PATH . DIRECTORY_SEPARATOR . 'core'); // search from core directory $this->findConfigFiles($folderPath); // search from modules directory + + if ($cache) { + if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { + $this->Application->setCache('master:config_files', serialize($this->configFiles)); + } + else { + $this->Application->setDBCache('config_files', serialize($this->configFiles)); + } + } } foreach ($this->configFiles as $filename) { @@ -311,6 +206,10 @@ throw new Exception('Prefix not defined in config file ' . $filename . ''); } } + + if ($cache) { + unset($this->configFiles); + } } /** @@ -354,7 +253,7 @@ $this->runAfterConfigRead($prefix); } - if (!isset($store_cache)) { + if ( !isset($store_cache) ) { // store cache not overrided -> use global setting $store_cache = $this->StoreCache; } @@ -371,7 +270,7 @@ $after_event = new kEvent('adm:OnAfterCacheRebuild'); $this->Application->HandleEvent($after_event); - $this->CacheParsedData(); + $this->Application->cacheManager->UpdateUnitCache(); if (defined('DEBUG_MODE') && DEBUG_MODE && defined('DBG_VALIDATE_CONFIGS') && DBG_VALIDATE_CONFIGS) { // validate configs here to have changes from OnAfterConfigRead hooks to prefixes