Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore "Packets out of order. Expected ..." Warnings #875

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
$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 '),

Check warning on line 213 in src/Driver/Pdo/AbstractPdoCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Driver/Pdo/AbstractPdoCommand.php#L213

Added line #L213 was not covered by tests
E_WARNING,
);

try {
$this->pdoStatement?->execute();
} finally {
restore_error_handler();
}
}
break;
} catch (PDOException $e) {
Expand Down
Loading