@@ -128,7 +128,7 @@ public function getProtocol(): ConnectionProtocol
128128 /**
129129 * @psalm-mutation-free
130130 */
131- public function getAccessMode (): AccessMode
131+ public function getAccessMode (): ? AccessMode
132132 {
133133 return $ this ->config ->getAccessMode ();
134134 }
@@ -217,7 +217,7 @@ public function begin(?string $database, ?float $timeout, BookmarkHolder $holder
217217 {
218218 $ this ->consumeResults ();
219219
220- $ extra = $ this ->buildRunExtra ($ database , $ timeout , $ holder , AccessMode:: WRITE () , $ txMetaData );
220+ $ extra = $ this ->buildRunExtra ($ database , $ timeout , $ holder , null , $ txMetaData );
221221 $ message = $ this ->messageFactory ->createBeginMessage ($ extra );
222222 $ response = $ message ->send ()->getResponse ();
223223 $ this ->assertNoFailure ($ response );
@@ -249,7 +249,7 @@ public function run(
249249 array $ parameters ,
250250 ?string $ database ,
251251 ?float $ timeout ,
252- BookmarkHolder $ holder ,
252+ ? BookmarkHolder $ holder ,
253253 ?AccessMode $ mode ,
254254 ?iterable $ tsxMetadata ,
255255 ): array {
@@ -295,7 +295,6 @@ public function protocol(): V4_4|V5|V5_1|V5_2|V5_3|V5_4
295295 public function pull (?int $ qid , ?int $ fetchSize ): array
296296 {
297297 $ extra = $ this ->buildResultExtra ($ fetchSize , $ qid );
298- $ this ->logger ?->log(LogLevel::DEBUG , 'PULL ' , $ extra );
299298
300299 $ tbr = [];
301300 $ message = $ this ->messageFactory ->createPullMessage ($ extra );
@@ -331,7 +330,7 @@ public function close(): void
331330 }
332331 }
333332
334- private function buildRunExtra (?string $ database , ?float $ timeout , BookmarkHolder $ holder , ?AccessMode $ mode , ?iterable $ metadata ): array
333+ private function buildRunExtra (?string $ database , ?float $ timeout , ? BookmarkHolder $ holder , ?AccessMode $ mode , ?iterable $ metadata ): array
335334 {
336335 $ extra = [];
337336 if ($ database !== null ) {
@@ -341,7 +340,7 @@ private function buildRunExtra(?string $database, ?float $timeout, BookmarkHolde
341340 $ extra ['tx_timeout ' ] = (int ) ($ timeout * 1000 );
342341 }
343342
344- if (!$ holder ->getBookmark ()->isEmpty ()) {
343+ if ($ holder && !$ holder ->getBookmark ()->isEmpty ()) {
345344 $ extra ['bookmarks ' ] = $ holder ->getBookmark ()->values ();
346345 }
347346
@@ -366,7 +365,7 @@ private function buildResultExtra(?int $fetchSize, ?int $qid): array
366365 $ extra ['n ' ] = $ fetchSize ;
367366 }
368367
369- if ($ qid !== null ) {
368+ if ($ qid !== null && $ qid >= 0 ) {
370369 $ extra ['qid ' ] = $ qid ;
371370 }
372371
@@ -420,6 +419,10 @@ public function assertNoFailure(Response $response): void
420419 */
421420 public function discardUnconsumedResults (): void
422421 {
422+ if (!in_array ($ this ->protocol ()->serverState , [ServerState::STREAMING , ServerState::TX_STREAMING ], true )) {
423+ return ;
424+ }
425+
423426 $ this ->logger ?->log(LogLevel::DEBUG , 'Discarding unconsumed results ' );
424427
425428 $ this ->subscribedResults = array_values (array_filter (
0 commit comments