Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2602,7 +2602,7 @@ public function escapeWhenCastingToString($escape = true)
*
* @return array
*/
public function __sleep()
public function __serialize()
{
$this->mergeAttributesFromCachedCasts();

Expand All @@ -2611,16 +2611,21 @@ public function __sleep()
$this->relationAutoloadCallback = null;
$this->relationAutoloadContext = null;

return array_keys(get_object_vars($this));
return get_object_vars($this);
}

/**
* When a model is being unserialized, check if it needs to be booted.
*
* @return void
*/
public function __wakeup()
public function __unserialize($data)
{
foreach ($data as $property => $value) {
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
}
$this->bootIfNotBooted();

$this->initializeTraits();
Expand Down
13 changes: 9 additions & 4 deletions src/Illuminate/Queue/Middleware/RateLimited.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ protected function getTimeUntilNextRetry($key)
*
* @return array
*/
public function __sleep()
public function __serialize()
{
return [
'limiterName',
'shouldRelease',
'limiterName' => $this->limiterName,
'shouldRelease' => $this->shouldRelease,
];
}

Expand All @@ -160,8 +160,13 @@ public function __sleep()
*
* @return void
*/
public function __wakeup()
public function __unserialize($data)
{
foreach ($data as $property => $value) {
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
}
$this->limiter = Container::getInstance()->make(RateLimiter::class);
}
}
9 changes: 7 additions & 2 deletions src/Illuminate/Queue/Middleware/RateLimitedWithRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,14 @@ protected function getTimeUntilNextRetry($key)
*
* @return void
*/
public function __wakeup()
public function __unserialize($data)
{
parent::__wakeup();
foreach ($data as $property => $value) {
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
}
parent::__unserialize($data);

$this->redis = Container::getInstance()->make(Redis::class);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Cache/Fixtures/Unserializable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Unserializable
{
public function __sleep()
public function __serialize()
{
throw new Exception('Not serializable');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Queue/CallQueuedHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function handle()
//
}

public function __wakeup()
public function __unserialize($data)
{
throw new ModelNotFoundException('Foo');
}
Expand All @@ -209,7 +209,7 @@ public function handle()
//
}

public function __wakeup()
public function __unserialize($data)
{
throw new ModelNotFoundException('Foo');
}
Expand Down