File tree Expand file tree Collapse file tree 5 files changed +29
-14
lines changed Expand file tree Collapse file tree 5 files changed +29
-14
lines changed Original file line number Diff line number Diff line change @@ -2601,8 +2601,8 @@ public function escapeWhenCastingToString($escape = true)
2601
2601
* Prepare the object for serialization.
2602
2602
*
2603
2603
* @return array
2604
- */
2605
- public function __sleep ()
2604
+ */
2605
+ public function __serialize ()
2606
2606
{
2607
2607
$ this ->mergeAttributesFromCachedCasts ();
2608
2608
@@ -2611,16 +2611,21 @@ public function __sleep()
2611
2611
$ this ->relationAutoloadCallback = null ;
2612
2612
$ this ->relationAutoloadContext = null ;
2613
2613
2614
- return array_keys ( get_object_vars ($ this ) );
2614
+ return get_object_vars ($ this );
2615
2615
}
2616
2616
2617
2617
/**
2618
2618
* When a model is being unserialized, check if it needs to be booted.
2619
2619
*
2620
2620
* @return void
2621
- */
2622
- public function __wakeup ( )
2621
+ */
2622
+ public function __unserialize ( $ data )
2623
2623
{
2624
+ foreach ($ data as $ property => $ value ) {
2625
+ if (property_exists ($ this , $ property )) {
2626
+ $ this ->{$ property } = $ value ;
2627
+ }
2628
+ }
2624
2629
$ this ->bootIfNotBooted ();
2625
2630
2626
2631
$ this ->initializeTraits ();
Original file line number Diff line number Diff line change @@ -147,11 +147,11 @@ protected function getTimeUntilNextRetry($key)
147
147
*
148
148
* @return array
149
149
*/
150
- public function __sleep ()
150
+ public function __serialize ()
151
151
{
152
152
return [
153
- 'limiterName ' ,
154
- 'shouldRelease ' ,
153
+ 'limiterName ' => $ this -> limiterName ,
154
+ 'shouldRelease ' => $ this -> shouldRelease ,
155
155
];
156
156
}
157
157
@@ -160,8 +160,13 @@ public function __sleep()
160
160
*
161
161
* @return void
162
162
*/
163
- public function __wakeup ( )
163
+ public function __unserialize ( $ data )
164
164
{
165
+ foreach ($ data as $ property => $ value ) {
166
+ if (property_exists ($ this , $ property )) {
167
+ $ this ->{$ property } = $ value ;
168
+ }
169
+ }
165
170
$ this ->limiter = Container::getInstance ()->make (RateLimiter::class);
166
171
}
167
172
}
Original file line number Diff line number Diff line change @@ -93,9 +93,14 @@ protected function getTimeUntilNextRetry($key)
93
93
*
94
94
* @return void
95
95
*/
96
- public function __wakeup ( )
96
+ public function __unserialize ( $ data )
97
97
{
98
- parent ::__wakeup ();
98
+ foreach ($ data as $ property => $ value ) {
99
+ if (property_exists ($ this , $ property )) {
100
+ $ this ->{$ property } = $ value ;
101
+ }
102
+ }
103
+ parent ::__unserialize ($ data );
99
104
100
105
$ this ->redis = Container::getInstance ()->make (Redis::class);
101
106
}
Original file line number Diff line number Diff line change 6
6
7
7
class Unserializable
8
8
{
9
- public function __sleep ()
9
+ public function __serialize ()
10
10
{
11
11
throw new Exception ('Not serializable ' );
12
12
}
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ public function handle()
195
195
//
196
196
}
197
197
198
- public function __wakeup ( )
198
+ public function __unserialize ( $ data )
199
199
{
200
200
throw new ModelNotFoundException ('Foo ' );
201
201
}
@@ -209,7 +209,7 @@ public function handle()
209
209
//
210
210
}
211
211
212
- public function __wakeup ( )
212
+ public function __unserialize ( $ data )
213
213
{
214
214
throw new ModelNotFoundException ('Foo ' );
215
215
}
You can’t perform that action at this time.
0 commit comments