Skip to content

Commit c87656f

Browse files
thundererdevnexen
authored andcommitted
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
1 parent 4476da4 commit c87656f

5 files changed

Lines changed: 34 additions & 3 deletions

File tree

‎NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ PHP NEWS
175175
- PGSQL:
176176
. Fixed bug GH-25772 (pg_fetch_object() crashes with JIT when the constructor
177177
keeps a reference and the result is discarded). (Tomasz Kowalczyk)
178+
. Fixed bug GH-25802 (pg_get_notify() result is never === false with opcache
179+
enabled). (Tomasz Kowalczyk)
178180

179181
- Phar:
180182
. Fixed bug GH-25528 (Phar::setSignatureAlgorithm(): OpenSSL signing reads a

‎Zend/Optimizer/zend_func_infos.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ static const func_info_t func_infos[] = {
333333
F1("pg_result_error_field", MAY_BE_STRING|MAY_BE_FALSE|MAY_BE_NULL),
334334
F1("pg_get_result", MAY_BE_OBJECT|MAY_BE_FALSE),
335335
F1("pg_result_status", MAY_BE_STRING|MAY_BE_LONG),
336-
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),
336+
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),
337337
F1("pg_socket", MAY_BE_RESOURCE|MAY_BE_FALSE),
338338
F1("pg_meta_data", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
339339
F1("pg_convert", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE),

‎ext/pgsql/pgsql.stub.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ function pg_get_result(PgSql\Connection $connection): PgSql\Result|false {}
906906
function pg_result_status(PgSql\Result $result, int $mode = PGSQL_STATUS_LONG): string|int {}
907907

908908
/**
909-
* @return array<int|string, int|string>
909+
* @return array<int|string, int|string>|false
910910
* @refcount 1
911911
*/
912912
function pg_get_notify(PgSql\Connection $connection, int $mode = PGSQL_ASSOC): array|false {}

‎ext/pgsql/pgsql_arginfo.h‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ext/pgsql/tests/gh25802.phpt‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
GH-25802: pg_get_notify() result is never === false with opcache enabled
3+
--EXTENSIONS--
4+
pgsql
5+
opcache
6+
--SKIPIF--
7+
<?php include("inc/skipif.inc"); ?>
8+
--INI--
9+
opcache.enable=1
10+
opcache.enable_cli=1
11+
opcache.file_update_protection=0
12+
--FILE--
13+
<?php
14+
include('inc/config.inc');
15+
16+
function check(PgSql\Connection $db): void {
17+
$msg = pg_get_notify($db);
18+
var_dump($msg === false);
19+
}
20+
21+
$db = pg_connect($conn_str);
22+
check($db);
23+
pg_query($db, 'LISTEN pg_get_notify_false');
24+
pg_query($db, 'NOTIFY pg_get_notify_false');
25+
check($db);
26+
?>
27+
--EXPECT--
28+
bool(true)
29+
bool(false)

0 commit comments

Comments
 (0)