Skip to content

Commit 8b4162f

Browse files
bug #62619 [Messenger] Fix PHP 8.5 deprecation for pgsqlGetNotify() in PostgreSQL transport (Shine-neko)
This PR was submitted for the 7.4 branch but it was merged into the 6.4 branch instead. Discussion ---------- [Messenger] Fix PHP 8.5 deprecation for pgsqlGetNotify() in PostgreSQL transport | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | License | MIT Fix a PHP 8.5 deprecation warning in the PostgreSQL messenger transport. In PHP 8.5, `PDO::pgsqlGetNotify()` is deprecated in favor of the new `Pdo\Pgsql::getNotify()` method. This change uses `instanceof` to detect the `Pdo\Pgsql` class and calls the appropriate method, maintaining backward compatibility with older PHP versions. Commits ------- 60efbba [Messenger] Fix PHP 8.5 deprecation for pgsqlGetNotify() in PostgreSQL transport
2 parents 39e0749 + 60efbba commit 8b4162f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/PostgreSqlConnectionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ public function pgsqlGetNotify()
7474
return false;
7575
}
7676

77+
public function getNotify()
78+
{
79+
++$this->notifyCalls;
80+
81+
return false;
82+
}
83+
7784
public function countNotifyCalls()
7885
{
7986
return $this->notifyCalls;

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class PostgreSqlConnection extends Connection
2626
{
2727
/**
2828
* * check_delayed_interval: The interval to check for delayed messages, in milliseconds. Set to 0 to disable checks. Default: 60000 (1 minute)
29-
* * get_notify_timeout: The length of time to wait for a response when calling PDO::pgsqlGetNotify, in milliseconds. Default: 0.
29+
* * get_notify_timeout: The length of time to wait for a response when calling PDO::pgsqlGetNotify (or Pdo\Pgsql::getNotify on PHP 8.4+), in milliseconds. Default: 0.
3030
*/
3131
protected const DEFAULT_OPTIONS = parent::DEFAULT_OPTIONS + [
3232
'check_delayed_interval' => 60000,
@@ -74,7 +74,9 @@ public function get(): ?array
7474
}
7575
}
7676

77-
$notification = $wrappedConnection->pgsqlGetNotify(\PDO::FETCH_ASSOC, $this->configuration['get_notify_timeout']);
77+
$notification = \PHP_VERSION_ID >= 80500
78+
? $wrappedConnection->getNotify(\PDO::FETCH_ASSOC, $this->configuration['get_notify_timeout'])
79+
: $wrappedConnection->pgsqlGetNotify(\PDO::FETCH_ASSOC, $this->configuration['get_notify_timeout']);
7880
if (
7981
// no notifications, or for another table or queue
8082
(false === $notification || $notification['message'] !== $this->configuration['table_name'] || $notification['payload'] !== $this->configuration['queue_name'])

0 commit comments

Comments
 (0)