Skip to content

Commit 42a4724

Browse files
exaby73transistive
authored andcommitted
fix: Consume results if server state in streaming
1 parent 5408df8 commit 42a4724

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/Bolt/BoltConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function setTimeout(float $timeout): void
151151

152152
public function consumeResults(): void
153153
{
154-
if ($this->protocol()->serverState !== ServerState::STREAMING || $this->protocol()->serverState !== ServerState::TX_STREAMING) {
154+
if ($this->protocol()->serverState !== ServerState::STREAMING && $this->protocol()->serverState !== ServerState::TX_STREAMING) {
155155
$this->subscribedResults = [];
156156
return;
157157
}

src/Bolt/BoltResult.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,6 @@ public function __destruct()
149149

150150
public function discard(): void
151151
{
152-
$serverState = $this->connection->protocol()->serverState;
153-
if ($serverState !== ServerState::STREAMING || $serverState !== ServerState::TX_STREAMING) {
154-
return;
155-
}
156152
$this->connection->discard($this->qid === -1 ? null : $this->qid);
157153
}
158154
}

src/Bolt/BoltUnmanagedTransaction.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Laudis\Neo4j\Bolt;
1515

16+
use Bolt\enum\ServerState;
1617
use Laudis\Neo4j\Common\TransactionHelper;
1718
use Laudis\Neo4j\Contracts\FormatterInterface;
1819
use Laudis\Neo4j\Contracts\UnmanagedTransactionInterface;
@@ -127,6 +128,11 @@ public function runStatement(Statement $statement)
127128
$parameters = ParameterHelper::formatParameters($statement->getParameters(), $this->connection->getProtocol());
128129
$start = microtime(true);
129130

131+
$serverState = $this->connection->protocol()->serverState;
132+
if (in_array($serverState, [ServerState::STREAMING, ServerState::TX_STREAMING])) {
133+
$this->connection->consumeResults();
134+
}
135+
130136
try {
131137
$meta = $this->connection->run(
132138
$statement->getText(),

0 commit comments

Comments
 (0)