Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c6149d3

Browse files
minor #39800 [Semaphore] Dont allow unserializing classes with a destructor (nicolas-grekas)
This PR was merged into the 5.2 branch. Discussion ---------- [Semaphore] Dont allow unserializing classes with a destructor | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- 92a2afb [Semaphore] Dont allow unserializing classes with a destructor
2 parents 2052534 + 92a2afb commit c6149d3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Symfony/Component/Semaphore/Semaphore.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public function __construct(Key $key, PersistingStoreInterface $store, float $tt
4848
$this->logger = new NullLogger();
4949
}
5050

51+
public function __sleep()
52+
{
53+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
54+
}
55+
56+
public function __wakeup()
57+
{
58+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
59+
}
60+
5161
/**
5262
* Automatically releases the underlying semaphore when the object is destructed.
5363
*/

0 commit comments

Comments
 (0)