[BUGFIX] Use SYSLOG_SEVERITY_* constant using t3lib_div::sysLog
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 2 Jul 2012 19:00:33 +0000 (21:00 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 2 Jul 2012 19:44:33 +0000 (21:44 +0200)
Use one of the defined SYSLOG_SEVERITY_* constants from t3lib_div
instead of an integer if calling t3lib_div::sysLog throughout the core.

Change-Id: I728d72dbe4966f34a0b291a53cdb41e1adc6062b
Fixes: #38571
Releases: 6.0
Reviewed-on: http://review.typo3.org/12526
Reviewed-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
14 files changed:
t3lib/cache/backend/class.t3lib_cache_backend_redisbackend.php
t3lib/class.t3lib_db.php
t3lib/class.t3lib_div.php
t3lib/class.t3lib_formmail.php
t3lib/class.t3lib_install.php
t3lib/class.t3lib_tsparser.php
t3lib/class.t3lib_userauth.php
t3lib/error/class.t3lib_error_abstractexceptionhandler.php
t3lib/utility/class.t3lib_utility_mail.php
tests/Unit/t3lib/class.t3lib_divTest.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/em/classes/index.php
typo3/sysext/openid/sv1/class.tx_openid_sv1.php
typo3/sysext/saltedpasswords/sv1/class.tx_saltedpasswords_sv1.php

index 51f0aeb..5b98977 100644 (file)
@@ -184,7 +184,11 @@ class t3lib_cache_backend_RedisBackend extends t3lib_cache_backend_AbstractBacke
                try {
                        $this->connected = $this->redis->connect($this->hostname, $this->port);
                } catch (Exception $e) {
-                       t3lib_div::sysLog('Could not connect to redis server.', 'core', 3);
+                       t3lib_div::sysLog(
+                               'Could not connect to redis server.',
+                               'core',
+                               t3lib_div::SYSLOG_SEVERITY_ERROR
+                       );
                }
 
                if ($this->connected) {
index a4eb418..cf874e3 100644 (file)
@@ -1082,7 +1082,7 @@ class t3lib_DB {
                        t3lib_div::sysLog('Could not connect to MySQL server ' . $TYPO3_db_host .
                                        ' with user ' . $TYPO3_db_username . ': ' . $error_msg,
                                'Core',
-                               4
+                               t3lib_div::SYSLOG_SEVERITY_FATAL
                        );
                } else {
                        $setDBinit = t3lib_div::trimExplode(LF, str_replace("' . LF . '", LF, $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']), TRUE);
@@ -1091,7 +1091,7 @@ class t3lib_DB {
                                        t3lib_div::sysLog('Could not initialize DB connection with query "' . $v .
                                                        '": ' . mysql_error($this->link),
                                                'Core',
-                                               3
+                                               t3lib_div::SYSLOG_SEVERITY_ERROR
                                        );
                                }
                        }
@@ -1121,7 +1121,7 @@ class t3lib_DB {
                                t3lib_div::sysLog(
                                        'NO_BACKSLASH_ESCAPES could not be removed from SQL mode: ' . $this->sql_error(),
                                        'Core',
-                                       3
+                                       t3lib_div::SYSLOG_SEVERITY_ERROR
                                );
                        }
                }
@@ -1140,7 +1140,7 @@ class t3lib_DB {
                        t3lib_div::sysLog('Could not select MySQL database ' . $TYPO3_db . ': ' .
                                        mysql_error(),
                                'Core',
-                               4
+                               t3lib_div::SYSLOG_SEVERITY_FATAL
                        );
                }
                return $ret;
@@ -1399,7 +1399,11 @@ class t3lib_DB {
                        $msg .= ': function t3lib_DB->' . $trace[0]['function'] . ' called from file ' .
                                        substr($trace[0]['file'], strlen(PATH_site) + 2) . ' in line ' .
                                        $trace[0]['line'];
-                       t3lib_div::sysLog($msg . '. Use a devLog extension to get more details.', 'Core/t3lib_db', 3);
+                       t3lib_div::sysLog(
+                               $msg . '. Use a devLog extension to get more details.',
+                               'Core/t3lib_db',
+                               t3lib_div::SYSLOG_SEVERITY_ERROR
+                       );
                                // Send to devLog if enabled
                        if (TYPO3_DLOG) {
                                $debugLogData = array(
index 50a7564..d3b071d 100644 (file)
@@ -5065,7 +5065,7 @@ final class t3lib_div {
         *
         * @param string $msg Message (in English).
         * @param string $extKey Extension key (from which extension you are calling the log) or "Core"
-        * @param integer $severity Severity: 0 is info, 1 is notice, 2 is warning, 3 is error, 4 is fatal error
+        * @param integer $severity t3lib_div::SYSLOG_SEVERITY_* constant
         * @return void
         */
        public static function sysLog($msg, $extKey, $severity = 0) {
index 78f6a30..a5d19e1 100644 (file)
@@ -145,9 +145,11 @@ class t3lib_formmail {
                                $autoRespondChecksum = $valueList['auto_respond_checksum'];
                                $correctHmacChecksum = t3lib_div::hmac($this->autoRespondMessage);
                                if ($autoRespondChecksum !== $correctHmacChecksum) {
-                                       t3lib_div::sysLog('Possible misuse of t3lib_formmail auto respond method. Subject: ' . $valueList['subject'],
+                                       t3lib_div::sysLog(
+                                               'Possible misuse of t3lib_formmail auto respond method. Subject: ' . $valueList['subject'],
                                                'Core',
-                                               3);
+                                               t3lib_div::SYSLOG_SEVERITY_ERROR
+                                       );
                                        return;
                                } else {
                                        $this->autoRespondMessage = $this->sanitizeHeaderString($this->autoRespondMessage);
@@ -192,13 +194,21 @@ class t3lib_formmail {
                                        continue;
                                }
                                if (!is_uploaded_file($_FILES[$variableName]['tmp_name'])) {
-                                       t3lib_div::sysLog('Possible abuse of t3lib_formmail: temporary file "' . $_FILES[$variableName]['tmp_name']
-                                                       . '" ("' . $_FILES[$variableName]['name'] . '") was not an uploaded file.', 'Core', 3);
+                                       t3lib_div::sysLog(
+                                               'Possible abuse of t3lib_formmail: temporary file "' . $_FILES[$variableName]['tmp_name'] .
+                                                       '" ("' . $_FILES[$variableName]['name'] . '") was not an uploaded file.',
+                                               'Core',
+                                               t3lib_div::SYSLOG_SEVERITY_ERROR
+                                       );
                                }
                                if ($_FILES[$variableName]['tmp_name']['error'] !== UPLOAD_ERR_OK) {
-                                       t3lib_div::sysLog('Error in uploaded file in t3lib_formmail: temporary file "'
-                                                       . $_FILES[$variableName]['tmp_name'] . '" ("' . $_FILES[$variableName]['name'] . '") Error code: '
-                                                       . $_FILES[$variableName]['tmp_name']['error'], 'Core', 3);
+                                       t3lib_div::sysLog(
+                                               'Error in uploaded file in t3lib_formmail: temporary file "' .
+                                                       $_FILES[$variableName]['tmp_name'] . '" ("' . $_FILES[$variableName]['name'] . '") Error code: ' .
+                                                       $_FILES[$variableName]['tmp_name']['error'],
+                                               'Core',
+                                               t3lib_div::SYSLOG_SEVERITY_ERROR
+                                       );
                                }
                                $theFile = t3lib_div::upload_to_tempfile($_FILES[$variableName]['tmp_name']);
                                $theName = $_FILES[$variableName]['name'];
@@ -230,7 +240,11 @@ class t3lib_formmail {
 
                                // Log dirty header lines
                        if ($this->dirtyHeaders) {
-                               t3lib_div::sysLog('Possible misuse of t3lib_formmail: see TYPO3 devLog', 'Core', 3);
+                               t3lib_div::sysLog(
+                                       'Possible misuse of t3lib_formmail: see TYPO3 devLog',
+                                       'Core',
+                                       t3lib_div::SYSLOG_SEVERITY_ERROR
+                               );
                                if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']) {
                                        t3lib_div::devLog('t3lib_formmail: ' . t3lib_div::arrayToLogString($this->dirtyHeaders, '', 200), 'Core', 3);
                                }
index b2d69c5..fbeebd7 100644 (file)
@@ -398,7 +398,7 @@ class t3lib_install {
                $this->messages[] = $msg;
 
                if (!$success) {
-                       t3lib_div::sysLog($msg, 'Core', 3);
+                       t3lib_div::sysLog($msg, 'Core', t3lib_div::SYSLOG_SEVERITY_ERROR);
                }
 
                return $success;
index 2d0d8ac..a610350 100644 (file)
@@ -310,7 +310,11 @@ class t3lib_TSparser {
                                                                                                $fakeThis = FALSE;
                                                                                                $newValue = t3lib_div::callUserFunction($hookMethod, $params, $fakeThis);
                                                                                        } else {
-                                                                                               t3lib_div::sysLog('Missing function definition for ' . $tsFunc . ' on TypoScript line ' . $lineP, 'Core', 2);
+                                                                                               t3lib_div::sysLog(
+                                                                                                       'Missing function definition for ' . $tsFunc . ' on TypoScript line ' . $lineP,
+                                                                                                       'Core',
+                                                                                                       t3lib_div::SYSLOG_SEVERITY_WARNING
+                                                                                               );
                                                                                        }
                                                                        }
 
@@ -565,7 +569,11 @@ class t3lib_TSparser {
        public static function checkIncludeLines($string, $cycle_counter = 1, $returnFiles = FALSE) {
                $includedFiles = array();
                if ($cycle_counter > 100) {
-                       t3lib_div::sysLog('It appears like TypoScript code is looping over itself. Check your templates for "&lt;INCLUDE_TYPOSCRIPT: ..." tags', 'Core', 2);
+                       t3lib_div::sysLog(
+                               'It appears like TypoScript code is looping over itself. Check your templates for "&lt;INCLUDE_TYPOSCRIPT: ..." tags',
+                               'Core',
+                               t3lib_div::SYSLOG_SEVERITY_WARNING
+                       );
                        if ($returnFiles) {
                                return array(
                                        'typoscript' => '',
@@ -612,11 +620,19 @@ class t3lib_TSparser {
                                                                                                $newString .= $included_text . LF;
                                                                                        } else {
                                                                                                $newString .= "\n###\n### ERROR: File \"" . $filename . "\" was not was not found.\n###\n\n";
-                                                                                               t3lib_div::sysLog('File "' . $filename . '" was not found.', 'Core', 2);
+                                                                                               t3lib_div::sysLog(
+                                                                                                       'File "' . $filename . '" was not found.',
+                                                                                                       'Core',
+                                                                                                       t3lib_div::SYSLOG_SEVERITY_WARNING
+                                                                                               );
                                                                                        }
                                                                                } else {
                                                                                        $newString .= "\n###\n### ERROR: File \"" . $filename . "\" was not included since it is not allowed due to fileDenyPattern\n###\n\n";
-                                                                                       t3lib_div::sysLog('File "' . $filename . '" was not included since it is not allowed due to fileDenyPattern', 'Core', 2);
+                                                                                       t3lib_div::sysLog(
+                                                                                               'File "' . $filename . '" was not included since it is not allowed due to fileDenyPattern',
+                                                                                               'Core',
+                                                                                               t3lib_div::SYSLOG_SEVERITY_WARNING
+                                                                                       );
                                                                                }
                                                                        }
                                                                break;
@@ -670,7 +686,11 @@ class t3lib_TSparser {
        public static function extractIncludes($string, $cycle_counter = 1, $extractedFileNames = array()) {
 
                if ($cycle_counter > 10) {
-                       t3lib_div::sysLog('It appears like TypoScript code is looping over itself. Check your templates for "&lt;INCLUDE_TYPOSCRIPT: ..." tags', 'Core', 2);
+                       t3lib_div::sysLog(
+                               'It appears like TypoScript code is looping over itself. Check your templates for "&lt;INCLUDE_TYPOSCRIPT: ..." tags',
+                               'Core',
+                               t3lib_div::SYSLOG_SEVERITY_WARNING
+                       );
                        return "\n###\n### ERROR: Recursion!\n###\n";
                }
 
index acd2b87..9f1897f 100644 (file)
@@ -409,7 +409,11 @@ abstract class t3lib_userAuth {
                                $match = array();
                                $matchCnt = @preg_match($cookieDomain, t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'), $match);
                                if ($matchCnt === FALSE) {
-                                       t3lib_div::sysLog('The regular expression for the cookie domain (' . $cookieDomain . ') contains errors. The session is not shared across sub-domains.', 'Core', 3);
+                                       t3lib_div::sysLog(
+                                               'The regular expression for the cookie domain (' . $cookieDomain . ') contains errors. The session is not shared across sub-domains.',
+                                               'Core',
+                                               t3lib_div::SYSLOG_SEVERITY_ERROR
+                                       );
                                } elseif ($matchCnt) {
                                        $result = $match[0];
                                }
index fd03917..51176f8 100644 (file)
@@ -72,7 +72,7 @@ abstract class t3lib_error_AbstractExceptionHandler implements t3lib_error_Excep
                $backtrace = $exception->getTrace();
 
                        // Write error message to the configured syslogs
-               t3lib_div::sysLog($logMessage, $logTitle, 4);
+               t3lib_div::sysLog($logMessage, $logTitle, t3lib_div::SYSLOG_SEVERITY_FATAL);
 
                        // When database credentials are wrong, the exception is probably
                        // caused by this. Therefor we cannot do any database operation,
index 35dc26a..91a5cc8 100644 (file)
@@ -104,7 +104,11 @@ final class t3lib_utility_Mail {
                }
 
                if (!$success) {
-                       t3lib_div::sysLog('Mail to "' . $to . '" could not be sent (Subject: "' . $subject . '").', 'Core', 3);
+                       t3lib_div::sysLog(
+                               'Mail to "' . $to . '" could not be sent (Subject: "' . $subject . '").',
+                               'Core',
+                               t3lib_div::SYSLOG_SEVERITY_ERROR
+                       );
                }
                return $success;
        }
index e8e658e..37d06f8 100644 (file)
@@ -4028,7 +4028,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
 
                        // Call method, get actual permissions and clean up
-               t3lib_div::syslog('testLog', 'test', 1);
+               t3lib_div::syslog('testLog', 'test', t3lib_div::SYSLOG_SEVERITY_NOTICE);
                clearstatcache();
                $resultFilePermissions = substr(decoct(fileperms($testLogFilename)), 2);
                t3lib_div::unlink_tempfile($testLogFilename);
index b3dda42..bb004b4 100644 (file)
@@ -383,7 +383,7 @@ class tslib_fe {
                                $warning = '&no_cache=1 has been supplied, so caching is disabled! URL: "'.t3lib_div::getIndpEnv('TYPO3_REQUEST_URL').'"';
                                $this->disableCache();
                        }
-                       t3lib_div::sysLog($warning, 'cms', 2);
+                       t3lib_div::sysLog($warning, 'cms', t3lib_div::SYSLOG_SEVERITY_WARNING);
                }
                $this->cHash = $cHash;
                $this->jumpurl = $jumpurl;
@@ -4178,7 +4178,11 @@ if (version == "n3") {
                $this->content = preg_replace('/(<(?:a|area).*?href=")(#[^"]*")/i', '${1}' . htmlspecialchars($scriptPath) . '${2}', $originalContent);
                        // There was an error in the call to preg_replace, so keep the original content (behavior prior to PHP 5.2)
                if (preg_last_error() > 0) {
-                       t3lib_div::sysLog('preg_replace returned error-code: ' . preg_last_error().' in function prefixLocalAnchorsWithScript. Replacement not done!', 'cms', 4);
+                       t3lib_div::sysLog(
+                               'preg_replace returned error-code: ' . preg_last_error().' in function prefixLocalAnchorsWithScript. Replacement not done!',
+                               'cms',
+                               t3lib_div::SYSLOG_SEVERITY_FATAL
+                       );
                        $this->content = $originalContent;
                }
        }
@@ -4422,7 +4426,7 @@ if (version == "n3") {
                        $this->disableCache();
                }
 
-               t3lib_div::sysLog($warning, 'cms', 2);
+               t3lib_div::sysLog($warning, 'cms', t3lib_div::SYSLOG_SEVERITY_WARNING);
        }
 
        /**
index 5bfd9aa..d3ce7c1 100644 (file)
@@ -1372,7 +1372,11 @@ class SC_mod_tools_em_index extends t3lib_SCbase {
                                // Read uploaded file:
                                if (!$uploadedTempFile) {
                                        if (!is_uploaded_file($_FILES['upload_ext_file']['tmp_name'])) {
-                                               t3lib_div::sysLog('Possible file upload attack: ' . $_FILES['upload_ext_file']['tmp_name'], 'Extension Manager', 3);
+                                               t3lib_div::sysLog(
+                                                       'Possible file upload attack: ' . $_FILES['upload_ext_file']['tmp_name'],
+                                                       'Extension Manager',
+                                                       t3lib_div::SYSLOG_SEVERITY_ERROR
+                                               );
 
                                                /** @var $flashMessage t3lib_FlashMessage */
                                                $flashMessage = t3lib_div::makeInstance(
index 4798bf1..9ca6434 100644 (file)
@@ -602,12 +602,12 @@ class tx_openid_sv1 extends t3lib_svbase {
                        $message = vsprintf($message, $params);
                }
                if (TYPO3_MODE == 'BE') {
-                       t3lib_div::sysLog($message, $this->extKey, 1);
+                       t3lib_div::sysLog($message, $this->extKey, t3lib_div::SYSLOG_SEVERITY_NOTICE);
                } else {
                        $GLOBALS['TT']->setTSlogMessage($message);
                }
                if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']) {
-                       t3lib_div::devLog($message, $this->extKey, 1);
+                       t3lib_div::devLog($message, $this->extKey, t3lib_div::SYSLOG_SEVERITY_NOTICE);
                }
        }
 }
index e115f97..5b6e3fa 100644 (file)
@@ -265,7 +265,7 @@ class tx_saltedpasswords_sv1 extends tx_sv_authbase {
                                                $this->login['uname']
                                        ),
                                        'Core',
-                                       0
+                                       t3lib_div::SYSLOG_SEVERITY_INFO
                                );
                                if (intval($this->extConf['onlyAuthService']) || $this->authenticationFailed) {
                                        $OK = 0;
@@ -301,7 +301,7 @@ class tx_saltedpasswords_sv1 extends tx_sv_authbase {
                                                $this->authInfo['HTTP_HOST']
                                        ),
                                        'Core',
-                                       0
+                                       t3lib_div::SYSLOG_SEVERITY_INFO
                                );
                                $OK = 0;
                        } elseif ($validPasswd) {
@@ -352,13 +352,13 @@ class tx_saltedpasswords_sv1 extends tx_sv_authbase {
                }
 
                if (TYPO3_MODE === 'BE') {
-                       t3lib_div::sysLog($message, $this->extKey, 1);
+                       t3lib_div::sysLog($message, $this->extKey, t3lib_div::SYSLOG_SEVERITY_NOTICE);
                } else {
                        $GLOBALS['TT']->setTSlogMessage($message);
                }
 
                if (TYPO3_DLOG) {
-                       t3lib_div::devLog($message, $this->extKey, 1);
+                       t3lib_div::devLog($message, $this->extKey, t3lib_div::SYSLOG_SEVERITY_NOTICE);
                }
        }
 }