Skip to content

Commit 06fcd84

Browse files
authored
Suppress "Packets out of order" warnings (#439)
1 parent b0cf5f5 commit 06fcd84

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- Enh #423: Refactor `DMLQueryBuilder::upsert()` method (@Tigrov)
5555
- Chg #428: Update expression namespaces according to changes in `yiisoft/db` package (@Tigrov)
5656
- Enh #432, #433: Update `DMLQueryBuilder::update()` method to adapt changes in `yiisoft/db` (@rustamwin, @Tigrov)
57+
- Enh #439: Move "Packets out of order" warning suppression from Yii DB (@vjik)
5758

5859
## 1.2.0 March 21, 2024
5960

src/Command.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Yiisoft\Db\Query\QueryInterface;
1313

1414
use function in_array;
15+
use function restore_error_handler;
16+
use function set_error_handler;
1517
use function str_starts_with;
1618
use function substr;
1719

@@ -146,4 +148,19 @@ public function showDatabases(): array
146148

147149
return $this->setSql($sql)->queryColumn();
148150
}
151+
152+
protected function pdoStatementExecute(): void
153+
{
154+
set_error_handler(
155+
static fn(int $errorNumber, string $errorString): bool =>
156+
str_starts_with($errorString, 'Packets out of order. Expected '),
157+
E_WARNING,
158+
);
159+
160+
try {
161+
$this->pdoStatement?->execute();
162+
} finally {
163+
restore_error_handler();
164+
}
165+
}
149166
}

0 commit comments

Comments
 (0)