Skip to content

Commit 108ccb6

Browse files
exaby73transistive
authored andcommitted
fix: Double results when iterating after deserialization
1 parent 7681d10 commit 108ccb6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Types/AbstractCypherSequence.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ public function __serialize(): array
564564
$this->preload();
565565

566566
$tbr = get_object_vars($this);
567-
$tbr['generator'] = new ArrayIterator($this->cache);
567+
$tbr['generator'] = new ArrayIterator();
568568
$tbr['currentPosition'] = 0;
569569
$tbr['generatorPosition'] = 0;
570570

tests/Unit/CypherListTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ public function setUp(): void
4747
$this->list = new CypherList(['A', 'B', 'C']);
4848
}
4949

50+
// https://github.com/neo4j-php/neo4j-php-client/issues/220
51+
public function testNoDoubleResultsAfterDeserialization(): void
52+
{
53+
$list = new CypherList(['A', 'B', 'C']);
54+
$serialized = serialize($list);
55+
$unserialized = unserialize($serialized);
56+
57+
$count = 0;
58+
foreach ($unserialized as $item) {
59+
++$count;
60+
}
61+
62+
self::assertEquals(3, $count);
63+
}
64+
5065
public function testFromIterableEqual(): void
5166
{
5267
$fromIterable = CypherList::fromIterable($this->list);

0 commit comments

Comments
 (0)