Commit c87656f16f2 for php
commit c87656f16f249fba44c249684bd677e2ada6885f
Author: Tomasz Kowalczyk <tomasz@kowalczyk.cc>
Date: Thu Nov 26 19:43:32 2026 +0100
ext/pgsql: pg_get_notify() result is never === false with opcache enabled
pg_get_notify() returns false when no notification is pending, but the
@return tag in the stub omitted |false. The generated optimizer info
therefore had no MAY_BE_FALSE, and opcache removed `=== false` checks on
the result, also with the JIT disabled.
This adds |false to the tag and regenerates the arginfo and optimizer
info. The test fails without the change.
Fix GH-25802
Close GH-25803
diff --git a/NEWS b/NEWS
index e42393462d8..e12f3020190 100644
--- a/NEWS
+++ b/NEWS
@@ -175,6 +175,8 @@ PHP NEWS
- PGSQL:
. Fixed bug GH-25772 (pg_fetch_object() crashes with JIT when the constructor
keeps a reference and the result is discarded). (Tomasz Kowalczyk)
+ . Fixed bug GH-25802 (pg_get_notify() result is never === false with opcache
+ enabled). (Tomasz Kowalczyk)
- Phar:
. Fixed bug GH-25528 (Phar::setSignatureAlgorithm(): OpenSSL signing reads a
diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h
index ce636919301..632e7bf98ba 100644
--- a/Zend/Optimizer/zend_func_infos.h
+++ b/Zend/Optimizer/zend_func_infos.h
@@ -333,7 +333,7 @@ static const func_info_t func_infos[] = {
F1("pg_result_error_field", MAY_BE_STRING|MAY_BE_FALSE|MAY_BE_NULL),
F1("pg_get_result", MAY_BE_OBJECT|MAY_BE_FALSE),
F1("pg_result_status", MAY_BE_STRING|MAY_BE_LONG),
- F1("pg_get_notify", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
+ F1("pg_get_notify", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("pg_socket", MAY_BE_RESOURCE|MAY_BE_FALSE),
F1("pg_meta_data", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
F1("pg_convert", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE),
diff --git a/ext/pgsql/pgsql.stub.php b/ext/pgsql/pgsql.stub.php
index 31774ed56fe..e9c5c392229 100644
--- a/ext/pgsql/pgsql.stub.php
+++ b/ext/pgsql/pgsql.stub.php
@@ -906,7 +906,7 @@ function pg_get_result(PgSql\Connection $connection): PgSql\Result|false {}
function pg_result_status(PgSql\Result $result, int $mode = PGSQL_STATUS_LONG): string|int {}
/**
- * @return array<int|string, int|string>
+ * @return array<int|string, int|string>|false
* @refcount 1
*/
function pg_get_notify(PgSql\Connection $connection, int $mode = PGSQL_ASSOC): array|false {}
diff --git a/ext/pgsql/pgsql_arginfo.h b/ext/pgsql/pgsql_arginfo.h
index 3839f550edb..5ee977a14f0 100644
Binary files a/ext/pgsql/pgsql_arginfo.h and b/ext/pgsql/pgsql_arginfo.h differ
diff --git a/ext/pgsql/tests/gh25802.phpt b/ext/pgsql/tests/gh25802.phpt
new file mode 100644
index 00000000000..2a1fa2711e0
--- /dev/null
+++ b/ext/pgsql/tests/gh25802.phpt
@@ -0,0 +1,29 @@
+--TEST--
+GH-25802: pg_get_notify() result is never === false with opcache enabled
+--EXTENSIONS--
+pgsql
+opcache
+--SKIPIF--
+<?php include("inc/skipif.inc"); ?>
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_update_protection=0
+--FILE--
+<?php
+include('inc/config.inc');
+
+function check(PgSql\Connection $db): void {
+ $msg = pg_get_notify($db);
+ var_dump($msg === false);
+}
+
+$db = pg_connect($conn_str);
+check($db);
+pg_query($db, 'LISTEN pg_get_notify_false');
+pg_query($db, 'NOTIFY pg_get_notify_false');
+check($db);
+?>
+--EXPECT--
+bool(true)
+bool(false)