Added feature #11669: Provide a reason for why $TSFE->set_no_cache() has been triggered
authorOliver Hader <oliver.hader@typo3.org>
Thu, 17 Sep 2009 18:41:58 +0000 (18:41 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Thu, 17 Sep 2009 18:41:58 +0000 (18:41 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5956 709f56b5-9817-0410-a4d7-c38de5d9e867

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

index 1903778..a605bb0 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@
 
        * Cleanup: Set SVN properties
        * Fixed bug #11985: Optimize disposal of t3lib_PageRenderer (thanks to Steffen Kamper)
+       * Added feature #11669: Provide a reason for why $TSFE->set_no_cache() has been triggered (thanks to Michael Stucki)
 
 2009-09-17  Sebastian Kurfuerst  <sebastian@typo3.org>
 
index 0cdd5ee..196ecbb 100644 (file)
@@ -4425,10 +4425,14 @@ if (version == "n3") {
        /**
         * Sets the cache-flag to 1. Could be called from user-included php-files in order to ensure that a page is not cached.
         *
+        * @param       string          $reason: An optional reason to be written to the syslog.
+        *                                              If not set, debug_backtrace() will be used to track down the call.
         * @return      void
         */
-       function set_no_cache() {
-               if (function_exists('debug_backtrace')) {
+       function set_no_cache($reason = '') {
+               if (strlen($reason)) {
+                       $warning = '$TSFE->set_no_cache() was triggered. Reason: ' . $reason . '.';
+               } else {
                        $trace = debug_backtrace();
                                // This is a hack to work around ___FILE___ resolving symbolic links
                        $PATH_site_real = str_replace('t3lib','',realpath(PATH_site.'t3lib'));
@@ -4440,18 +4444,18 @@ if (version == "n3") {
                        }
                        $line = $trace[0]['line'];
                        $trigger = $file.' on line '.$line;
-               } else {
-                       $trigger = '[unknown]';
+
+                       $warning = '$TSFE->set_no_cache() was triggered by ' . $trigger.'.';
                }
 
-               $warning = '$TSFE->set_no_cache() was triggered by '.$trigger.'. ';
                if ($this->TYPO3_CONF_VARS['FE']['disableNoCacheParameter']) {
-                       $warning.= 'However $TYPO3_CONF_VARS[\'FE\'][\'disableNoCacheParameter\'] is set, so it will be ignored!';
+                       $warning.= ' However, $TYPO3_CONF_VARS[\'FE\'][\'disableNoCacheParameter\'] is set, so it will be ignored!';
                        $GLOBALS['TT']->setTSlogMessage($warning,2);
                } else {
-                       $warning.= 'Caching is disabled!';
+                       $warning.= ' Caching is disabled!';
                        $this->no_cache = 1;
                }
+
                t3lib_div::sysLog($warning, 'cms', 2);
        }