Skip to content

Commit 60efbba

Browse files
Shine-nekonicolas-grekas
authored andcommitted
[Messenger] Fix PHP 8.5 deprecation for pgsqlGetNotify() in PostgreSQL transport
1 parent 39e0749 commit 60efbba

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)