Skip to content

Commit c6129f1

Browse files
ArshidArshid
authored andcommitted
Replace __wakeup with __unserialize for object unserialization
1 parent 7b5e185 commit c6129f1

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2603,8 +2603,13 @@ public function __sleep()
26032603
*
26042604
* @return void
26052605
*/
2606-
public function __wakeup()
2606+
public function __unserialize($data)
26072607
{
2608+
foreach ($data as $property => $value) {
2609+
if (property_exists($this, $property)) {
2610+
$this->{$property} = $value;
2611+
}
2612+
}
26082613
$this->bootIfNotBooted();
26092614

26102615
$this->initializeTraits();

src/Illuminate/Queue/Middleware/RateLimited.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,13 @@ public function __sleep()
160160
*
161161
* @return void
162162
*/
163-
public function __wakeup()
163+
public function __unserialize($data)
164164
{
165+
foreach ($data as $property => $value) {
166+
if (property_exists($this, $property)) {
167+
$this->{$property} = $value;
168+
}
169+
}
165170
$this->limiter = Container::getInstance()->make(RateLimiter::class);
166171
}
167172
}

src/Illuminate/Queue/Middleware/RateLimitedWithRedis.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,15 @@ protected function getTimeUntilNextRetry($key)
9393
*
9494
* @return void
9595
*/
96-
public function __wakeup()
96+
public function __unserialize($data)
9797
{
98-
parent::__wakeup();
98+
foreach ($data as $property => $value) {
99+
if (property_exists($this, $property)) {
100+
$this->{$property} = $value;
101+
}
102+
}
103+
104+
parent::__unserialize($data);
99105

100106
$this->redis = Container::getInstance()->make(Redis::class);
101107
}

tests/Integration/Queue/CallQueuedHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function handle()
195195
//
196196
}
197197

198-
public function __wakeup()
198+
public function __unserialize($data)
199199
{
200200
throw new ModelNotFoundException('Foo');
201201
}
@@ -209,7 +209,7 @@ public function handle()
209209
//
210210
}
211211

212-
public function __wakeup()
212+
public function __unserialize($data)
213213
{
214214
throw new ModelNotFoundException('Foo');
215215
}

0 commit comments

Comments
 (0)