Commit 1cdfa4dacd6 for php

commit 1cdfa4dacd6c669a4cd8d6abeb9050dda5aff3f6
Author: Harp404 <234041561+Harp404@users.noreply.github.com>
Date:   Fri Dec 4 07:03:04 2026 +0000

    Fix GH-26058: filter_var_array() ignores options passed by reference (#26060)

    Dereference each filter definition before checking whether it is an array.
    This lets filter_var_array() and filter_input_array() apply options held
    by reference. Previously, the options array was converted to a filter ID
    and the requested filter was ignored.

    Cover both an options array and an integer filter ID held by reference.

    Fixes #26058

    Closes #26060

diff --git a/NEWS b/NEWS
index b6106e37db8..2d97165c2ec 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP                                                                        NEWS
   . Fixed enchant_broker_set_dict_path() and enchant_broker_get_dict_path()
     returning null with libenchant 2. Both now return false. (lacatoire)

+- Filter:
+  . Fixed bug GH-26058 (Creating a reference to a filter_var_array option
+    breaks the filtering). (Harp404)
+
 - Intl:
   . Fixed stale or missing global error code and message in MessageFormatter
     and IntlDateFormatter::formatObject(). (ChrisAbner)
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
index a98fc56df24..58bafee1271 100644
--- a/ext/filter/filter.c
+++ b/ext/filter/filter.c
@@ -595,6 +595,7 @@ static void php_filter_array_handler(zval *input, HashTable *op_ht, zend_long op
 			} else {
 				zval nval;
 				ZVAL_DEREF(tmp);
+				ZVAL_DEREF(arg_elm);
 				ZVAL_DUP(&nval, tmp);
 				php_filter_call(&nval, -1,
 					Z_TYPE_P(arg_elm) == IS_ARRAY ? Z_ARRVAL_P(arg_elm) : NULL,
diff --git a/ext/filter/tests/gh26058.phpt b/ext/filter/tests/gh26058.phpt
new file mode 100644
index 00000000000..2c71836aecf
--- /dev/null
+++ b/ext/filter/tests/gh26058.phpt
@@ -0,0 +1,31 @@
+--TEST--
+GH-26058 (Creating a reference to a filter_var_array option breaks the filtering)
+--EXTENSIONS--
+filter
+--FILE--
+<?php
+
+$data = [
+    'key1' => "asdf",
+    'key2' => "42",
+    'key3' => "x",
+];
+$options = [
+    'key1' => ['filter' => FILTER_VALIDATE_INT],
+    'key2' => ['filter' => FILTER_VALIDATE_INT],
+    'key3' => FILTER_VALIDATE_INT,
+];
+
+array_walk($options, fn(&$x) => $x);
+var_dump(filter_var_array($data, $options));
+
+?>
+--EXPECT--
+array(3) {
+  ["key1"]=>
+  bool(false)
+  ["key2"]=>
+  int(42)
+  ["key3"]=>
+  bool(false)
+}