1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-07 21:56:31 +02:00

Fix serialization implementation

This commit is contained in:
Jordi Boggiano
2023-02-06 14:43:38 +01:00
parent 3e92e9d243
commit c8b1e0e789
2 changed files with 6 additions and 2 deletions

View File

@@ -741,7 +741,7 @@ class Logger implements LoggerInterface, ResettableInterface
{ {
foreach (['name', 'handlers', 'processors', 'microsecondTimestamps', 'timezone', 'exceptionHandler', 'logDepth', 'detectCycles'] as $property) { foreach (['name', 'handlers', 'processors', 'microsecondTimestamps', 'timezone', 'exceptionHandler', 'logDepth', 'detectCycles'] as $property) {
if (isset($data[$property])) { if (isset($data[$property])) {
$this->$property = $data; $this->$property = $data[$property];
} }
} }

View File

@@ -700,7 +700,11 @@ class LoggerTest extends \PHPUnit\Framework\TestCase
public function testSerializable() public function testSerializable()
{ {
$logger = new Logger(__METHOD__); $logger = new Logger(__METHOD__);
self::assertInstanceOf(Logger::class, unserialize(serialize($logger))); $copy = unserialize(serialize($logger));
self::assertInstanceOf(Logger::class, $copy);
self::assertSame($logger->getName(), $copy->getName());
self::assertSame($logger->getTimezone()->getName(), $copy->getTimezone()->getName());
self::assertSame($logger->getHandlers(), $copy->getHandlers());
} }
public function testReset() public function testReset()