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)
26012601 * Prepare the object for serialization.
26022602 *
26032603 * @return array
2604- */
2605- public function __sleep ()
2604+ */
2605+ public function __serialize ()
26062606 {
26072607 $ this ->mergeAttributesFromCachedCasts ();
26082608
@@ -2611,16 +2611,21 @@ public function __sleep()
26112611 $ this ->relationAutoloadCallback = null ;
26122612 $ this ->relationAutoloadContext = null ;
26132613
2614- return array_keys ( get_object_vars ($ this ) );
2614+ return get_object_vars ($ this );
26152615 }
26162616
26172617 /**
26182618 * When a model is being unserialized, check if it needs to be booted.
26192619 *
26202620 * @return void
2621- */
2622- public function __wakeup ( )
2621+ */
2622+ public function __unserialize ( $ data )
26232623 {
2624+ foreach ($ data as $ property => $ value ) {
2625+ if (property_exists ($ this , $ property )) {
2626+ $ this ->{$ property } = $ value ;
2627+ }
2628+ }
26242629 $ this ->bootIfNotBooted ();
26252630
26262631 $ this ->initializeTraits ();
Original file line number Diff line number Diff line change @@ -147,11 +147,11 @@ protected function getTimeUntilNextRetry($key)
147147 *
148148 * @return array
149149 */
150- public function __sleep ()
150+ public function __serialize ()
151151 {
152152 return [
153- 'limiterName ' ,
154- 'shouldRelease ' ,
153+ 'limiterName ' => $ this -> limiterName ,
154+ 'shouldRelease ' => $ this -> shouldRelease ,
155155 ];
156156 }
157157
@@ -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}
Original file line number Diff line number Diff line change @@ -93,9 +93,14 @@ 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+ parent ::__unserialize ($ data );
99104
100105 $ this ->redis = Container::getInstance ()->make (Redis::class);
101106 }
Original file line number Diff line number Diff line change 66
77class Unserializable
88{
9- public function __sleep ()
9+ public function __serialize ()
1010 {
1111 throw new Exception ('Not serializable ' );
1212 }
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments