Skip to content

Commit 0e3a4bf

Browse files
committed
Fix bug when messages contain colons
1 parent d18eb57 commit 0e3a4bf

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Monolog/Handler/DeduplicationHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private function isDuplicate(array $record)
117117
$line = $record['level_name'] . ':' . $record['message'];
118118

119119
for ($i = count($store) - 1; $i >= 0; $i--) {
120-
list($timestamp, $level, $message) = explode(':', $store[$i]);
120+
list($timestamp, $level, $message) = explode(':', $store[$i], 3);
121121

122122
if ($level === $record['level_name'] && $message === $record['message'] && $timestamp > $timestampValidity) {
123123
return true;

tests/Monolog/Handler/DeduplicationHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testFlushPassthruIfEmptyLog()
4545
@unlink(sys_get_temp_dir().'/monolog_dedup.log');
4646
$handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0);
4747

48-
$handler->handle($this->getRecord(Logger::ERROR));
48+
$handler->handle($this->getRecord(Logger::ERROR, 'Foo:bar'));
4949
$handler->handle($this->getRecord(Logger::CRITICAL));
5050

5151
$handler->flush();
@@ -66,7 +66,7 @@ public function testFlushSkipsIfLogExists()
6666
$test = new TestHandler();
6767
$handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0);
6868

69-
$handler->handle($this->getRecord(Logger::ERROR));
69+
$handler->handle($this->getRecord(Logger::ERROR, 'Foo:bar'));
7070
$handler->handle($this->getRecord(Logger::CRITICAL));
7171

7272
$handler->flush();

0 commit comments

Comments
 (0)