[BUGFIX] Check for enabled devlog inside devLog() 07/53207/2
authorBenni Mack <benni@typo3.org>
Fri, 19 May 2017 12:24:24 +0000 (14:24 +0200)
committerBenni Mack <benni@typo3.org>
Wed, 14 Jun 2017 15:42:44 +0000 (17:42 +0200)
Calling GeneralUtility::devLog() can be called but
the method itself should check whether the devlog
is enabled, instead of having third-party code
rely on checking the option with an if statement.

This effectively removes the need for checks on
if (TYPO3_DLOG) and the other two constants TYPO3_ERROR_DLOG
and TYPO3_EXCEPTION_DLOG in all callers' code.

Resolves: #80289
Releases: master, 8.7
Change-Id: Ibaeeca6300bdb37a513a07fb46c2616cfc51c7f2
Reviewed-on: https://review.typo3.org/53207
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php
typo3/sysext/core/Classes/Error/AbstractExceptionHandler.php
typo3/sysext/core/Classes/Error/ErrorHandler.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/frontend/Classes/Http/RequestHandler.php
typo3/sysext/saltedpasswords/Classes/SaltedPasswordService.php

index 451ea2c..eccac0d 100644 (file)
@@ -664,9 +664,7 @@ function jumpToUrl(URL) {
 </div>' : '') . $this->endOfPageJsBlock;
 
         // Logging: Can't find better place to put it:
-        if (TYPO3_DLOG) {
-            GeneralUtility::devLog('END of BACKEND session', \TYPO3\CMS\Backend\Template\DocumentTemplate::class, 0, ['_FLUSH' => true]);
-        }
+        GeneralUtility::devLog('END of BACKEND session', \TYPO3\CMS\Backend\Template\DocumentTemplate::class, 0, ['_FLUSH' => true]);
         return $str;
     }
 
index dcbed6f..4e3a211 100644 (file)
@@ -382,7 +382,7 @@ abstract class AbstractUserAuthentication
         if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['writeDevLog' . $this->loginType]) {
             $this->writeDevLog = true;
         }
-        if (TYPO3_DLOG) {
+        if ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']) {
             $this->writeDevLog = true;
         }
         if ($this->writeDevLog) {
index 84cda39..d61ae88 100644 (file)
@@ -74,13 +74,10 @@ abstract class AbstractExceptionHandler implements ExceptionHandlerInterface, \T
         // otherwise this will lead into recurring exceptions.
         try {
             // Write error message to devlog
-            // see: $TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG']
-            if (TYPO3_EXCEPTION_DLOG) {
-                GeneralUtility::devLog($logMessage, $logTitle, 3, [
-                    'TYPO3_MODE' => TYPO3_MODE,
-                    'backtrace' => $backtrace
-                ]);
-            }
+            GeneralUtility::devLog($logMessage, $logTitle, 3, [
+                'TYPO3_MODE' => TYPO3_MODE,
+                'backtrace' => $backtrace
+            ]);
             // Write error message to sys_log table
             $this->writeLog($logTitle . ': ' . $logMessage);
         } catch (\Exception $exception) {
index e701a39..21d7277 100644 (file)
@@ -131,10 +131,8 @@ class ErrorHandler implements ErrorHandlerInterface
                 GeneralUtility::sysLog($message, 'core', $severity + 1);
             }
             // Write error message to devlog extension(s),
-            // see: $TYPO3_CONF_VARS['SYS']['enable_errorDLOG']
-            if (TYPO3_ERROR_DLOG) {
-                GeneralUtility::devLog($message, 'core', $severity + 1);
-            }
+            GeneralUtility::devLog($message, 'core', $severity + 1);
+
             // Write error message to TSlog (admin panel)
             $timeTracker = $this->getTimeTracker();
             if (is_object($timeTracker)) {
index 77cf3de..36c6e37 100644 (file)
@@ -4346,8 +4346,8 @@ class GeneralUtility
      * This should be implemented around the source code, both frontend and backend, logging everything from the flow through an application, messages, results from comparisons to fatal errors.
      * The result is meant to make sense to developers during development or debugging of a site.
      * The idea is that this function is only a wrapper for external extensions which can set a hook which will be allowed to handle the logging of the information to any format they might wish and with any kind of filter they would like.
-     * If you want to implement the devLog in your applications, simply add lines like:
-     * if (TYPO3_DLOG) \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[write message in english here]', 'extension key');
+     * If you want to implement the devLog in your applications, simply add a line like:
+     * \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[write message in english here]', 'extension key');
      *
      * @param string $msg Message (in english).
      * @param string $extKey Extension key (from which extension you are calling the log)
@@ -4356,7 +4356,7 @@ class GeneralUtility
      */
     public static function devLog($msg, $extKey, $severity = 0, $dataVar = false)
     {
-        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'])) {
+        if ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG'] && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'])) {
             $params = ['msg' => $msg, 'extKey' => $extKey, 'severity' => $severity, 'dataVar' => $dataVar];
             $fakeThis = false;
             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'] as $hookMethod) {
index 0895d8a..9d850c7 100644 (file)
@@ -271,9 +271,7 @@ class RequestHandler implements RequestHandlerInterface
         if (isset($GLOBALS['error']) && is_object($GLOBALS['error']) && @is_callable([$GLOBALS['error'], 'debugOutput'])) {
             $GLOBALS['error']->debugOutput();
         }
-        if (TYPO3_DLOG) {
-            GeneralUtility::devLog('END of FRONTEND session', 'cms', 0, ['_FLUSH' => true]);
-        }
+        GeneralUtility::devLog('END of FRONTEND session', 'cms', 0, ['_FLUSH' => true]);
         return $response;
     }
 
index f69b464..63cfd6d 100644 (file)
@@ -257,8 +257,6 @@ class SaltedPasswordService extends \TYPO3\CMS\Sv\AbstractAuthenticationService
             $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
             $timeTracker->setTSlogMessage($message);
         }
-        if (TYPO3_DLOG) {
-            GeneralUtility::devLog($message, $this->extKey, GeneralUtility::SYSLOG_SEVERITY_NOTICE);
-        }
+        GeneralUtility::devLog($message, $this->extKey, GeneralUtility::SYSLOG_SEVERITY_NOTICE);
     }
 }