Skip to content

Commit 891797c

Browse files
committed
Dont allow unserializing classes with a destructor - 5.2
1 parent a77cbec commit 891797c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Response/CommonResponseTrait.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ public function toStream(bool $throw = true)
127127
return $stream;
128128
}
129129

130+
public function __sleep()
131+
{
132+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
133+
}
134+
135+
public function __wakeup()
136+
{
137+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
138+
}
139+
130140
/**
131141
* Closes the response and all its network handles.
132142
*/

Response/TraceableResponse.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ public function __construct(HttpClientInterface $client, ResponseInterface $resp
4444
$this->event = $event;
4545
}
4646

47+
public function __sleep()
48+
{
49+
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
50+
}
51+
52+
public function __wakeup()
53+
{
54+
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
55+
}
56+
4757
public function __destruct()
4858
{
4959
try {

0 commit comments

Comments
 (0)