From fcb01c30e668f1318d63171a16153dd7293d32cb Mon Sep 17 00:00:00 2001
From: Thomas Hohn <thomas@hohn.dk>
Date: Fri, 3 Mar 2023 06:26:38 +0100
Subject: [PATCH] [TASK] Streamline logging in method TSFE->set_no_cache
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The logging in the method set_no_cache should not depend on the calling
parameter $internal. Instead it should be notice in both cases.
Since it's possible to change the general log level during development
or debugging the entries will still be visible, just not on production
systems which makes good sense.
In addition the variable $internal was renamed to $internalRequest in order to make the purpose clearer.

Resolves: #100067
Related: #97815
Releases: main, 11.5
Change-Id: I59af542e22c2a6ad65ad42e0fc3d2c64f0408f76
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78010
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Jörg Bösche <typo3@joergboesche.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Controller/TypoScriptFrontendController.php    | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
index d23010850275..6cd1e8708c4d 100644
--- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
+++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
@@ -2589,9 +2589,9 @@ class TypoScriptFrontendController implements LoggerAwareInterface
      * 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 log.
-     * @param bool $internal Whether the call is done from core itself (should only be used by core).
+     * @param bool $internalRequest Whether the request is internal or not (true should only be used by core calls).
      */
-    public function set_no_cache($reason = '', $internal = false)
+    public function set_no_cache($reason = '', $internalRequest = false)
     {
         $warning = '';
         $context = [];
@@ -2615,18 +2615,14 @@ class TypoScriptFrontendController implements LoggerAwareInterface
             }
             $context['line'] = $trace[0]['line'];
         }
-        if (!$internal && $GLOBALS['TYPO3_CONF_VARS']['FE']['disableNoCacheParameter']) {
+        if (!$internalRequest && $GLOBALS['TYPO3_CONF_VARS']['FE']['disableNoCacheParameter']) {
             $warning .= ' However, $TYPO3_CONF_VARS[\'FE\'][\'disableNoCacheParameter\'] is set, so it will be ignored!';
-            $this->getTimeTracker()->setTSlogMessage($warning, LogLevel::WARNING);
+            $this->getTimeTracker()->setTSlogMessage($warning, LogLevel::NOTICE);
         } else {
             $warning .= ' Caching is disabled!';
             $this->disableCache();
         }
-        if ($internal) {
-            $this->logger->notice($warning, $context);
-        } else {
-            $this->logger->warning($warning, $context);
-        }
+        $this->logger->notice($warning, $context);
     }
 
     /**
-- 
GitLab