Fixed feature request #5424: Menu cache expire time should be configurable
authorOliver Hader <oliver.hader@typo3.org>
Mon, 30 Apr 2007 09:28:32 +0000 (09:28 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 30 Apr 2007 09:28:32 +0000 (09:28 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2307 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/class.tslib_menu.php

index 34853b1..26da534 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-04-30  Oliver Hader  <oh@inpublica.de>
+
+       * Fixed feature request #5424: Menu cache expire time should be configurable
+
 2007-04-28  Ernesto Baschny  <ernst@cron-it.de>
 
        * Fixed bug #4957: CSV export stop exporting a field when there is a linebreak. Thanks for Oliver Klee for the idea and solution.
index 230a747..93e584e 100755 (executable)
         * @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));
@@ -3892,6 +3892,25 @@ if (version == "n3") {
        }
 
        /**
+        * 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)
         * It will also find all links to http:// in the text and substitute with a shorter link using the redirect feature which stores the long link in the database. Depends on configuration in TS 'config.notification_email_urlmode'
index d5c7b25..6bd3814 100755 (executable)
@@ -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');