Commit 684612c85b9 for php

commit 684612c85b992f13ed04bdaad10970a47dcea3f0
Author: Tomasz Kowalczyk <tomasz@kowalczyk.cc>
Date:   Wed Nov 25 20:27:12 2026 +0100

    ext/pgsql: fix pg_fetch_all_columns() JIT crash on a modified empty result

    Since 8f6bc97a360, pg_fetch_all_columns() returns the shared immutable empty
    array for a result without rows. The stub still declared @refcount 1, which
    lets function JIT and tracing JIT modify the result in place and crash. Drop
    the annotation.

    Fix GH-25760
    Close GH-25761

diff --git a/NEWS b/NEWS
index c5602d1cf86..99cb66865da 100644
--- a/NEWS
+++ b/NEWS
@@ -155,6 +155,10 @@ PHP                                                                        NEWS
   . Fixed bug GH-25588 (Use-after-free of a string parameter omitted on a later
     execute() or rebound while fetching). (Ilia Alshanetsky)

+- PGSQL:
+  . Fixed bug GH-25760 (pg_fetch_all_columns() crashes with JIT when the result
+    for an empty set is modified). (Tomasz Kowalczyk)
+
 - Phar:
   . Fixed bug GH-25528 (Phar::setSignatureAlgorithm(): OpenSSL signing reads a
     freed private key). (Artem Ukrainskiy)
diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h
index be2a0c3639b..a02fce257ce 100644
--- a/Zend/Optimizer/zend_func_infos.h
+++ b/Zend/Optimizer/zend_func_infos.h
@@ -319,7 +319,7 @@ static const func_info_t func_infos[] = {
 	F1("pg_fetch_array", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_NULL|MAY_BE_FALSE),
 	F1("pg_fetch_object", MAY_BE_OBJECT|MAY_BE_FALSE),
 	F1("pg_fetch_all", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY),
-	F1("pg_fetch_all_columns", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_NULL),
+	FN("pg_fetch_all_columns", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_NULL),
 	F1("pg_last_oid", MAY_BE_STRING|MAY_BE_LONG|MAY_BE_FALSE),
 	F1("pg_lo_create", MAY_BE_STRING|MAY_BE_LONG|MAY_BE_FALSE),
 	F1("pg_lo_open", MAY_BE_OBJECT|MAY_BE_FALSE),
diff --git a/ext/pgsql/pgsql.stub.php b/ext/pgsql/pgsql.stub.php
index 9bd78eb3ad4..61d41dcffc2 100644
--- a/ext/pgsql/pgsql.stub.php
+++ b/ext/pgsql/pgsql.stub.php
@@ -654,7 +654,6 @@ function pg_fetch_all(PgSql\Result $result, int $mode = PGSQL_ASSOC): array {}

     /**
      * @return array<int, string|null>
-     * @refcount 1
      */
     function pg_fetch_all_columns(PgSql\Result $result, int $field = 0): array {}

diff --git a/ext/pgsql/pgsql_arginfo.h b/ext/pgsql/pgsql_arginfo.h
index c9b0c85880d..294212cf355 100644
Binary files a/ext/pgsql/pgsql_arginfo.h and b/ext/pgsql/pgsql_arginfo.h differ
diff --git a/ext/pgsql/tests/gh25760.phpt b/ext/pgsql/tests/gh25760.phpt
new file mode 100644
index 00000000000..69148e9a043
--- /dev/null
+++ b/ext/pgsql/tests/gh25760.phpt
@@ -0,0 +1,31 @@
+--TEST--
+GH-25760: pg_fetch_all_columns() crashes with JIT when the result for an empty set is modified
+--EXTENSIONS--
+pgsql
+opcache
+--SKIPIF--
+<?php include("inc/skipif.inc"); ?>
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=function
+opcache.jit_buffer_size=64M
+opcache.file_update_protection=0
+--FILE--
+<?php
+include("inc/config.inc");
+
+function test(PgSql\Result $result) {
+    $columns = pg_fetch_all_columns($result);
+    $columns[] = 1;
+    return $columns;
+}
+
+$conn = pg_connect($conn_str);
+var_dump(test(pg_query($conn, "SELECT 1 WHERE false")));
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  int(1)
+}