Commit 33cdf363263 for php.net

commit 33cdf36326319995a973d6009c0df34dcdc76292
Author: David Carlier <devnexen@gmail.com>
Date:   Thu Jul 30 08:11:23 2026 +0100

    Use zend_hash_add_new_ptr() for the user_filter_map insertion.

    The volatile factory registration above already rejects a duplicate filter
    name, so the name cannot be in the map either. The add_new variant asserts
    that invariant in debug builds.

    Close GH-22838

diff --git a/NEWS b/NEWS
index 425a48481a9..4e95bed34c8 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,8 @@ PHP                                                                        NEWS
     filegroup(), fileatime(), filemtime(), filectime(), filetype(),
     is_writable(), is_readable(), is_executable(), is_file(), is_dir(),
     is_link(), file_exists(), lstat(), stat(). (Girgias)
+  . Fixed bug GH-22818 (stream_filter_register() orphaned user_filter_map on
+    shutdown re-registration). (David Carlier)

 30 Jul 2026, PHP 8.6.0alpha3

diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c
index d69af26912c..e65ddd78ba4 100644
--- a/ext/standard/user_filters.c
+++ b/ext/standard/user_filters.c
@@ -613,8 +613,9 @@ PHP_FUNCTION(stream_filter_register)
 		zend_hash_init(BG(user_filter_map), 8, NULL, NULL, 0);
 	}

-	/* The factory has just been (re)registered, so keep the map in sync. */
-	zend_hash_update_ptr(BG(user_filter_map), filtername, ce);
+	/* The factory registration above already rejected a duplicate name, so the
+	 * filter name cannot be present in the map either. */
+	zend_hash_add_new_ptr(BG(user_filter_map), filtername, ce);

 	RETURN_TRUE;
 }