diff options
author | Ben Burgess <88810029+bx80@users.noreply.github.com> | 2022-03-30 05:37:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-30 05:37:24 +0300 |
commit | 3b91641d4fb2e66ae4ae481d65e2532b5fe3ab25 (patch) | |
tree | 8f7cdcf7be7c59f23aa4ff34fbe99610917f78b9 /core | |
parent | 5e27e6fd0b9fc1c925cfc68715d9dfaec050250a (diff) |
Skip web server error logs for unsupported browser exceptions (#19018)
Diffstat (limited to 'core')
-rw-r--r-- | core/ExceptionHandler.php | 7 | ||||
-rw-r--r-- | core/testMinimumPhpVersion.php | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/core/ExceptionHandler.php b/core/ExceptionHandler.php index a6af86354f..4a61495a85 100644 --- a/core/ExceptionHandler.php +++ b/core/ExceptionHandler.php @@ -146,7 +146,12 @@ class ExceptionHandler } } - $result = Piwik_GetErrorMessagePage($message, $debugTrace, true, true, $logoHeaderUrl, $logoFaviconUrl); + // Unsupported browser errors shouldn't be written to the web server log. At DEBUG logging level this error will + // be written to the application log instead + $writeErrorLog = !($ex instanceof \Piwik\Exception\NotSupportedBrowserException); + + $result = Piwik_GetErrorMessagePage($message, $debugTrace, true, true, $logoHeaderUrl, + $logoFaviconUrl, null, $writeErrorLog); try { /** diff --git a/core/testMinimumPhpVersion.php b/core/testMinimumPhpVersion.php index 8412e5c243..70fa5310bf 100644 --- a/core/testMinimumPhpVersion.php +++ b/core/testMinimumPhpVersion.php @@ -109,12 +109,15 @@ if (!function_exists('Piwik_GetErrorMessagePage')) { * @param bool $optionalLinkBack If true, displays a link to go back * @param bool|string $logoUrl The URL to the logo to use. * @param bool|string $faviconUrl The URL to the favicon to use. + * @param bool $writeErrorLog If true then a webserver error log will be written, defaults to true * @return string */ function Piwik_GetErrorMessagePage($message, $optionalTrace = false, $optionalLinks = false, $optionalLinkBack = false, - $logoUrl = false, $faviconUrl = false, $isCli = null) + $logoUrl = false, $faviconUrl = false, $isCli = null, bool $writeErrorLog = true) { - error_log(sprintf("Error in Matomo: %s", str_replace("\n", " ", strip_tags($message)))); + if ($writeErrorLog) { + error_log(sprintf("Error in Matomo: %s", str_replace("\n", " ", strip_tags($message)))); + } if (!headers_sent()) { header('Content-Type: text/html; charset=utf-8'); |