Skip to content

Commit

Permalink
Fix serialization implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Feb 6, 2023
1 parent 3e92e9d commit c8b1e0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ public function __unserialize(array $data): void
{
foreach (['name', 'handlers', 'processors', 'microsecondTimestamps', 'timezone', 'exceptionHandler', 'logDepth', 'detectCycles'] as $property) {
if (isset($data[$property])) {
$this->$property = $data;
$this->$property = $data[$property];
}
}

Expand Down
6 changes: 5 additions & 1 deletion tests/Monolog/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,11 @@ public function testCustomHandleException()
public function testSerializable()
{
$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()
Expand Down

0 comments on commit c8b1e0e

Please sign in to comment.