diff --git a/CHANGELOG.md b/CHANGELOG.md index be112319f..1903f2ac5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ - Enh #865: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov, @vjik) - Enh #798: Allow `QueryInterface::one()` and `QueryInterface::all()` to return objects (@darkdef, @Tigrov) - Enh #864: Realize column factory (@Tigrov) +- Enh #875: Ignore "Packets out of order..." warnings in `AbstractPdoCommand::internalExecute()` method (@Tigrov) ## 1.3.0 March 21, 2024 diff --git a/src/Driver/Pdo/AbstractPdoCommand.php b/src/Driver/Pdo/AbstractPdoCommand.php index 7a31bba2c..bfcb018b5 100644 --- a/src/Driver/Pdo/AbstractPdoCommand.php +++ b/src/Driver/Pdo/AbstractPdoCommand.php @@ -23,6 +23,10 @@ use Yiisoft\Db\Query\Data\DataReader; use Yiisoft\Db\QueryBuilder\QueryBuilderInterface; +use function restore_error_handler; +use function set_error_handler; +use function str_starts_with; + /** * Represents a database command that can be executed using a PDO (PHP Data Object) database connection. * @@ -204,7 +208,17 @@ protected function internalExecute(): void $this->isolationLevel ); } else { - $this->pdoStatement?->execute(); + 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(); + } } break; } catch (PDOException $e) {