From 9873cb71e66be0f80839c76e923c3b866dd23b46 Mon Sep 17 00:00:00 2001 From: dizzy Date: Thu, 12 Aug 2021 00:13:00 -0700 Subject: avoid large amounts of notifications being added to the session (#17736) * impose limit on notification message size when logging to notifications * if in memory notification count exceeds max notification size in session, do not attempt to new ones it to the session * Detect when session was too large to read and provide warning to user. * add some tests for Notification\ManagerTest.php * add tests for relevant DbTable members * Change session data column type to allow larger session data values. * update to rc3 * trigger new build? * fix namespace * fix test namespaces * bump version correctly --- plugins/Monolog/Handler/WebNotificationHandler.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/Monolog/Handler/WebNotificationHandler.php b/plugins/Monolog/Handler/WebNotificationHandler.php index 0269282c9f..c365403590 100644 --- a/plugins/Monolog/Handler/WebNotificationHandler.php +++ b/plugins/Monolog/Handler/WebNotificationHandler.php @@ -20,6 +20,8 @@ use Zend_Session_Exception; */ class WebNotificationHandler extends AbstractProcessingHandler { + const MAX_NOTIFICATION_MESSAGE_LENGTH = 512; + public function isHandling(array $record) { if (!empty($record['context']['ignoreInScreenWriter'])) { @@ -46,7 +48,11 @@ class WebNotificationHandler extends AbstractProcessingHandler break; } - $message = $record['level_name'] . ': ' . htmlentities($record['message'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); + $recordMessage = $record['message']; + $recordMessage = str_replace(PIWIK_INCLUDE_PATH, '', $recordMessage); + $recordMessage = substr($recordMessage, 0, self::MAX_NOTIFICATION_MESSAGE_LENGTH); + + $message = $record['level_name'] . ': ' . htmlentities($recordMessage, ENT_COMPAT | ENT_HTML401, 'UTF-8'); $message .= $this->getLiteDebuggingInfo(); $notification = new Notification($message); -- cgit v1.2.3