Skip to content

Commit

Permalink
Ignore "Packets out of order. Expected ..." Warnings (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored Aug 30, 2024
1 parent 99d69c1 commit 2f82ef6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- Enh #862: Refactor PHP type of `ColumnSchemaInterface` instances (@Tigrov)
- 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 #875: Ignore "Packets out of order..." warnings in `AbstractPdoCommand::internalExecute()` method (@Tigrov)

## 1.3.0 March 21, 2024

Expand Down
16 changes: 15 additions & 1 deletion src/Driver/Pdo/AbstractPdoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2f82ef6

Please sign in to comment.