Przeglądaj źródła

Fix bug when messages contain colons

Jordi Boggiano 9 lat temu
rodzic
commit
0e3a4bf48b

+ 1 - 1
src/Monolog/Handler/DeduplicationHandler.php

@@ -117,7 +117,7 @@ class DeduplicationHandler extends BufferHandler
         $line = $record['level_name'] . ':' . $record['message'];
 
         for ($i = count($store) - 1; $i >= 0; $i--) {
-            list($timestamp, $level, $message) = explode(':', $store[$i]);
+            list($timestamp, $level, $message) = explode(':', $store[$i], 3);
 
             if ($level === $record['level_name'] && $message === $record['message'] && $timestamp > $timestampValidity) {
                 return true;

+ 2 - 2
tests/Monolog/Handler/DeduplicationHandlerTest.php

@@ -45,7 +45,7 @@ class DeduplicationHandlerTest extends TestCase
         @unlink(sys_get_temp_dir().'/monolog_dedup.log');
         $handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0);
 
-        $handler->handle($this->getRecord(Logger::ERROR));
+        $handler->handle($this->getRecord(Logger::ERROR, 'Foo:bar'));
         $handler->handle($this->getRecord(Logger::CRITICAL));
 
         $handler->flush();
@@ -66,7 +66,7 @@ class DeduplicationHandlerTest extends TestCase
         $test = new TestHandler();
         $handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0);
 
-        $handler->handle($this->getRecord(Logger::ERROR));
+        $handler->handle($this->getRecord(Logger::ERROR, 'Foo:bar'));
         $handler->handle($this->getRecord(Logger::CRITICAL));
 
         $handler->flush();