neo4j-php / neo4j-php-client

Php client and driver for neo4j database
https://neo4j.com/developer/php/
MIT License
159 stars 40 forks source link

Upgrade to 3.1 breaks our foreach loops #220

Closed tim-hanssen closed 1 month ago

tim-hanssen commented 1 month ago

Upgrading from 3.0 to 3.1 breaks our implementation. All results are returned double (except result 0, the first) when foreaching a Laudis\Neo4j\Databags\SummarizedResult.

If instead of directly foreaching we use the ->toArray() on the object, the number of rows is back to normal.

Expected behavior Foreach of the object results in the same result as toArray() and not double them.

Desktop (please complete the following information):

We also receive a PHP warning from a linked class:

Implicit conversion from float 9.223372036854776E+18 to int loses precision in /vendor/laudis/neo4j-php-client/src/Types/AbstractCypherSequence.php on line 529
exaby73 commented 1 month ago

Hello @tim-hanssen. Could you provide a code sample I could use to reproduce and investigate this issue?

exaby73 commented 1 month ago

We just released 3.1.1. This should address the "implicit conversion" warning you get. Let us know if this version fixes your issue as we weren't able to reproduce it

tim-hanssen commented 1 month ago

Hey @exaby73 so the warning is indeed fixed in 3.1.1, but the double loop is still the same.

It happens after we retrieve the object from a cache layer in a clean Laravel install. I guess it's serializing the class so it can be stored into redis.

        $data = Cache::remember('save-me', 604800, function () {

                     // THIS RETURNS a Laudis\Neo4j\Databags\SummarizedResult class.
            });
exaby73 commented 1 month ago

I found the issue to be serialization/deserialization of the CypherList class causing results to be double. I'm working on a fix and will update soon

exaby73 commented 1 month ago

@tim-hanssen 3.1.2 should be the fix you're looking for :) Thanks for bringing this up so we could catch it early