Skip to content

Commit 4b18b32

Browse files
Merge branch '3.4' into 4.2
* 3.4: Prevent destructors with side-effects from being unserialized
2 parents abd8b95 + d77e445 commit 4b18b32

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ private function findSutFqcn($test)
102102
return $sutFqcn;
103103
}
104104

105+
public function __sleep()
106+
{
107+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
108+
}
109+
110+
public function __wakeup()
111+
{
112+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
113+
}
114+
105115
public function __destruct()
106116
{
107117
if (!$this->warnings) {

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 10 additions & 0 deletions
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) {

src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php

Lines changed: 10 additions & 0 deletions
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();

src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ public static function throwError($type, $message, $file, $line)
122122
throw new \ErrorException($message, 0, $type, $file, $line);
123123
}
124124

125+
public function __sleep()
126+
{
127+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
128+
}
129+
130+
public function __wakeup()
131+
{
132+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
133+
}
134+
125135
public function __destruct()
126136
{
127137
if (method_exists(parent::class, '__destruct')) {

0 commit comments

Comments
 (0)