diff --git a/CHANGELOG.md b/CHANGELOG.md index cd9a990c..5ff49cc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ - Enh #423: Refactor `DMLQueryBuilder::upsert()` method (@Tigrov) - Chg #428: Update expression namespaces according to changes in `yiisoft/db` package (@Tigrov) - Enh #432, #433: Update `DMLQueryBuilder::update()` method to adapt changes in `yiisoft/db` (@rustamwin, @Tigrov) +- Enh #439: Move "Packets out of order" warning suppression from Yii DB (@vjik) ## 1.2.0 March 21, 2024 diff --git a/src/Command.php b/src/Command.php index 9ec1d3d4..b46be204 100644 --- a/src/Command.php +++ b/src/Command.php @@ -12,6 +12,8 @@ use Yiisoft\Db\Query\QueryInterface; use function in_array; +use function restore_error_handler; +use function set_error_handler; use function str_starts_with; use function substr; @@ -146,4 +148,19 @@ public function showDatabases(): array return $this->setSql($sql)->queryColumn(); } + + protected function pdoStatementExecute(): void + { + set_error_handler( + static fn(int $errorNumber, string $errorString): bool => + str_starts_with($errorString, 'Packets out of order. Expected '), + E_WARNING, + ); + + try { + $this->pdoStatement?->execute(); + } finally { + restore_error_handler(); + } + } }