Skip to content

Commit f9cfda8

Browse files
Vitexusoz-agent
andcommitted
fix: __serialize() returns proper key-value pairs for session serialization
- __serialize() now returns associative array instead of flat property name list - __unserialize() assigns values directly with is_string guard - __sleep() now returns property names from __serialize() - Removed non-existent 'init' property from serialization list Fixes TypeError: Ease\Molecule::setupProperty() Argument #2 must be string, int given Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent a8c3ca4 commit f9cfda8

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/AbraFlexi/RO.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,9 @@ public function __toString()
396396
public function __unserialize(array $data): void
397397
{
398398
foreach ($data as $key => $value) {
399-
$this->setupProperty($data, $key);
399+
if (\is_string($key) && property_exists($this, $key)) {
400+
$this->{$key} = $value;
401+
}
400402
}
401403

402404
$this->curlInit();
@@ -419,7 +421,7 @@ public function __wakeup(): void
419421
*/
420422
public function __serialize(): array
421423
{
422-
return [
424+
$properties = [
423425
'data',
424426
'objectName',
425427
'nameSpace',
@@ -436,7 +438,6 @@ public function __serialize(): array
436438
'password',
437439
'defaultHttpHeaders',
438440
'defaultUrlParams',
439-
'init',
440441
'nameColumn',
441442
'myCreateColumn',
442443
'myLastModifiedColumn',
@@ -454,18 +455,28 @@ public function __serialize(): array
454455
'timeout',
455456
'throwException',
456457
];
458+
459+
$result = [];
460+
461+
foreach ($properties as $property) {
462+
if (property_exists($this, $property)) {
463+
$result[$property] = $this->{$property};
464+
}
465+
}
466+
467+
return $result;
457468
}
458469

459470
/**
460471
* Variables to keep during serialization.
461472
*
462473
* @deprecated Soft deprecated in PHP 8.5
463474
*
464-
* @return array<string, mixed>
475+
* @return array<int, string>
465476
*/
466477
public function __sleep()
467478
{
468-
$this->__serialize();
479+
return array_keys($this->__serialize());
469480
}
470481

471482
/**

0 commit comments

Comments
 (0)