From: Oliver Hader Date: Mon, 30 Apr 2007 09:28:32 +0000 (+0000) Subject: Fixed feature request #5424: Menu cache expire time should be configurable X-Git-Tag: TYPO3_4-2-0alpha1~117 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/a1658cc98ebda885933b2a731fdd051920c85547 Fixed feature request #5424: Menu cache expire time should be configurable git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2307 709f56b5-9817-0410-a4d7-c38de5d9e867 --- diff --git a/ChangeLog b/ChangeLog index 34853b15a344..26da534e498e 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-04-30 Oliver Hader + + * Fixed feature request #5424: Menu cache expire time should be configurable + 2007-04-28 Ernesto Baschny * Fixed bug #4957: CSV export stop exporting a field when there is a linebreak. Thanks for Oliver Klee for the idea and solution. diff --git a/typo3/sysext/cms/tslib/class.tslib_fe.php b/typo3/sysext/cms/tslib/class.tslib_fe.php index 230a747c8aae..93e584efb7a3 100755 --- a/typo3/sysext/cms/tslib/class.tslib_fe.php +++ b/typo3/sysext/cms/tslib/class.tslib_fe.php @@ -2458,7 +2458,7 @@ * @return void */ function realPageCacheContent() { - $cache_timeout = $this->page['cache_timeout'] ? $this->page['cache_timeout'] : ($this->cacheTimeOutDefault ? $this->cacheTimeOutDefault : 60*60*24); // seconds until a cached page is too old + $cache_timeout = $this->get_cache_timeout(); // seconds until a cached page is too old $timeOutTime = $GLOBALS['EXEC_TIME']+$cache_timeout; if ($this->config['config']['cache_clearAtMidnight']) { $midnightTime = mktime (0,0,0,date('m',$timeOutTime),date('d',$timeOutTime),date('Y',$timeOutTime)); @@ -3891,6 +3891,25 @@ if (version == "n3") { $this->cacheTimeOutDefault = intval($seconds); } + /** + * Get the cache timeout for the current page. + * + * @return integer The cache timeout for the current page. + */ + function get_cache_timeout() { + // Cache period was set for the page: + if ($this->page['cache_timeout']) { + $cacheTimeout = $this->page['cache_timeout']; + // Cache period was set for the whole site: + } elseif ($this->cacheTimeOutDefault) { + $cacheTimeout = $this->cacheTimeOutDefault; + // No cache period set at all, so we take one day (60*60*24 seconds = 86400 seconds): + } else { + $cacheTimeout = 86400; + } + return $cacheTimeout; + } + /** * Substitute function for the PHP mail() function. * It will encode the email with the setting of TS 'config.notification_email_encoding' (base64 or none) diff --git a/typo3/sysext/cms/tslib/class.tslib_menu.php b/typo3/sysext/cms/tslib/class.tslib_menu.php index d5c7b25b87e2..6bd38148a608 100755 --- a/typo3/sysext/cms/tslib/class.tslib_menu.php +++ b/typo3/sysext/cms/tslib/class.tslib_menu.php @@ -836,7 +836,13 @@ class tslib_menu { } $this->hash = md5(serialize($this->menuArr).serialize($this->mconf).serialize($this->tmpl->rootLine).serialize($this->MP_array)); - $serData = $this->sys_page->getHash($this->hash, 60*60*24); + // Get the cache timeout: + if ($this->conf['cache_period']) { + $cacheTimeout = $this->conf['cache_period']; + } else { + $cacheTimeout = $GLOBALS['TSFE']->get_cache_timeout(); + } + $serData = $this->sys_page->getHash($this->hash, $cacheTimeout); if (!$serData) { $this->generate(); $this->sys_page->storeHash($this->hash, serialize($this->result),'MENUDATA');