Skip to content

PHP 8.5 deprecation: PDO::pgsqlGetNotify() in StreamDoctrineDbalStore #827

@freerich

Description

@freerich

Description

PHP 8.5 deprecated PDO::pgsqlGetNotify() in favor of Pdo\Pgsql::getNotify(). This causes deprecation notices when running subscriptions:

Deprecated: Method PDO::pgsqlGetNotify() is deprecated since 8.5,
use Pdo\Pgsql::getNotify() instead

Location

Both StreamDoctrineDbalStore.php and DoctrineDbalStore.php, method wait() — on 3.19.x and 4.0.x:

/** @var PDO $nativeConnection */
$nativeConnection = $this->connection->getNativeConnection();
$nativeConnection->pgsqlGetNotify(PDO::FETCH_ASSOC, $timeoutMilliseconds);

Suggested fix

Both branches support PHP 8.2+, but Pdo\Pgsql was only introduced in PHP 8.4, so a compatibility check is needed:

$nativeConnection = $this->connection->getNativeConnection();

if ($nativeConnection instanceof \Pdo\Pgsql) {
    $nativeConnection->getNotify(\PDO::FETCH_ASSOC, $timeoutMilliseconds);
} else {
    /** @var PDO $nativeConnection */
    $nativeConnection->pgsqlGetNotify(\PDO::FETCH_ASSOC, $timeoutMilliseconds);
}

Alternatively, if the minimum PHP version is bumped to 8.4+ in a future release, this simplifies to:

/** @var \Pdo\Pgsql $nativeConnection */
$nativeConnection = $this->connection->getNativeConnection();
$nativeConnection->getNotify(\PDO::FETCH_ASSOC, $timeoutMilliseconds);

Affected versions

Both 3.19.x and 4.0.x (both require ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0).

Environment

  • PHP 8.5
  • patchlevel/event-sourcing 3.18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions