Skip to content

Commit bca96ed

Browse files
committed
fixed bug when destructing a result set in READY state
1 parent 5e49536 commit bca96ed

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.1.7-cli
1+
FROM php:8.1-cli
22
RUN apt-get update \
33
&& apt-get install -y \
44
libzip-dev \

src/Bolt/BoltConnection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,9 @@ public function pull(?int $qid, ?int $fetchSize): array
363363
public function __destruct()
364364
{
365365
if ($this->serverState !== 'FAILED' && $this->isOpen()) {
366-
$this->consumeResults();
366+
if (in_array($this->serverState, ['STREAMING', 'TX_STREAMING'])) {
367+
$this->consumeResults();
368+
}
367369

368370
$this->protocol()->goodbye();
369371

src/Bolt/BoltResult.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313

1414
namespace Laudis\Neo4j\Bolt;
1515

16+
use Laudis\Neo4j\Contracts\FormatterInterface;
1617
use function array_splice;
1718
use function count;
1819
use Generator;
1920
use Iterator;
2021

2122
/**
22-
* @psalm-import-type BoltCypherStats from \Laudis\Neo4j\Contracts\FormatterInterface
23+
* @psalm-import-type BoltCypherStats from FormatterInterface
2324
*
2425
* @implements Iterator<int, list>
2526
*/

src/Bolt/ConnectionPool.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ public function release(ConnectionInterface $connection): void
109109
}
110110
}
111111

112+
public function __destruct()
113+
{
114+
echo 'Destructing connection pool';
115+
}
116+
112117
/**
113118
* @return BoltConnection|null
114119
*/
@@ -117,7 +122,7 @@ private function returnAnyAvailableConnection(SessionConfiguration $config): ?Co
117122
$streamingConnection = null;
118123
$requiresReconnectConnection = null;
119124
// Ensure random connection reuse before picking one.
120-
shuffle($this->activeConnections);
125+
// shuffle($this->activeConnections);
121126

122127
foreach ($this->activeConnections as $activeConnection) {
123128
// We prefer a connection that is just ready

src/Bolt/Session.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,9 @@ public function getLastBookmark(): Bookmark
194194
{
195195
return $this->bookmarkHolder->getBookmark();
196196
}
197+
198+
public function __destruct()
199+
{
200+
echo 'destroyed session';
201+
}
197202
}

0 commit comments

Comments
 (0)