Skip to content

Commit

Permalink
Merge branch '4.2'
Browse files Browse the repository at this point in the history
* 4.2:
  Prevent destructors with side-effects from being unserialized
  • Loading branch information
nicolas-grekas committed Apr 16, 2019
2 parents 14ba16b + 4b18b32 commit d140648
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ private function findSutFqcn($test)
return $sutFqcn;
}

public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

public function __destruct()
{
if (!$this->warnings) {
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ public function __construct(array $mockedNamespaces = array())
}
}

public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

public function __destruct()
{
if (0 < $this->state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ public function getLogDir()
return $this->cacheDir;
}

public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

public function __destruct()
{
$fs = new Filesystem();
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ public static function throwError($type, $message, $file, $line)
throw new \ErrorException($message, 0, $type, $file, $line);
}

public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

public function __destruct()
{
if (method_exists(parent::class, '__destruct')) {
Expand Down

0 comments on commit d140648

Please sign in to comment.