-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix serializability of Logger class, fixes #1792
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -722,4 +722,34 @@ protected function handleException(Throwable $e, array $record): void | |
|
||
($this->exceptionHandler)($e, $record); | ||
} | ||
|
||
public function __serialize(): array | ||
{ | ||
return [ | ||
'name' => $this->name, | ||
'handlers' => $this->handlers, | ||
'processors' => $this->processors, | ||
'microsecondTimestamps' => $this->microsecondTimestamps, | ||
'timezone' => $this->timezone, | ||
'exceptionHandler' => $this->exceptionHandler, | ||
'logDepth' => $this->logDepth, | ||
'detectCycles' => $this->detectCycles, | ||
]; | ||
} | ||
|
||
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 comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Seldaek
Author
Owner
|
||
} | ||
} | ||
|
||
if (\PHP_VERSION_ID >= 80100) { | ||
// Local variable for phpstan, see https://github.com/phpstan/phpstan/issues/6732#issuecomment-1111118412 | ||
/** @var \WeakMap<\Fiber, int> $fiberLogDepth */ | ||
$fiberLogDepth = new \WeakMap(); | ||
$this->fiberLogDepth = $fiberLogDepth; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shouldn't this be
data[$property]
?