Skip to content

Commit 34542b7

Browse files
bug #39794 Dont allow unserializing classes with a destructor - 4.4 (jderusse)
This PR was merged into the 4.4 branch. Discussion ---------- Dont allow unserializing classes with a destructor - 4.4 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Prevent destructors with side-effects from being unserialized Commits ------- 955395c999 Dont allow unserializing classes with a destructor - 4.4
2 parents 0969043 + 89e8975 commit 34542b7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

BufferingLogger.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public function cleanLogs(): array
3535
return $logs;
3636
}
3737

38+
public function __sleep()
39+
{
40+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
41+
}
42+
43+
public function __wakeup()
44+
{
45+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
46+
}
47+
3848
public function __destruct()
3949
{
4050
foreach ($this->logs as [$level, $message, $context]) {

0 commit comments

Comments
 (0)