Skip to content

Commit 4fb9752

Browse files
Prevent destructors with side-effects from being unserialized
1 parent 3a861ac commit 4fb9752

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

Diff for: src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

+10
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ public function __construct(array $mockedNamespaces = array())
8383
}
8484
}
8585

86+
public function __sleep()
87+
{
88+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
89+
}
90+
91+
public function __wakeup()
92+
{
93+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
94+
}
95+
8696
public function __destruct()
8797
{
8898
if (0 < $this->state) {

Diff for: src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php

+10
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ public function getLogDir()
6464
return $this->cacheDir;
6565
}
6666

67+
public function __sleep()
68+
{
69+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
70+
}
71+
72+
public function __wakeup()
73+
{
74+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
75+
}
76+
6777
public function __destruct()
6878
{
6979
$fs = new Filesystem();

Diff for: src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php

+10
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ public static function throwError($type, $message, $file, $line)
116116
throw new \ErrorException($message, 0, $type, $file, $line);
117117
}
118118

119+
public function __sleep()
120+
{
121+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
122+
}
123+
124+
public function __wakeup()
125+
{
126+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
127+
}
128+
119129
public function __destruct()
120130
{
121131
if (method_exists(parent::class, '__destruct')) {

0 commit comments

Comments
 (0)