Commit bd8a9bd3b15 for php.net

commit bd8a9bd3b15e5959fe5b23343475f0efa0bda2e7
Author: David Carlier <devnexen@gmail.com>
Date:   Sat Jun 20 05:01:24 2026 +0100

    Fix GH-22360: convert.base64-encode corruption on incremental flush.

    Fix #22360

    close GH-22368

diff --git a/NEWS b/NEWS
index 9a1b6d35d1f..1b6809def6c 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP                                                                        NEWS
   . Fixed bug GH-22324 (Ignore leading namespace separator in
     ReflectionParameter::__construct()). (jorgsowa)

+- Standard:
+  . Fixed bug GH-22360 (convert.base64-encode corruption on
+    incremental flush). (David Carlier)
+
 02 Jul 2026, PHP 8.4.23

 - Core:
diff --git a/ext/standard/filters.c b/ext/standard/filters.c
index d0fdd0f1f68..a7c0a035a23 100644
--- a/ext/standard/filters.c
+++ b/ext/standard/filters.c
@@ -1519,7 +1519,7 @@ static php_stream_filter_status_t strfilter_convert_filter(
 		php_stream_bucket_delref(bucket);
 	}

-	if (flags != PSFS_FLAG_NORMAL) {
+	if (flags & PSFS_FLAG_FLUSH_CLOSE) {
 		if (strfilter_convert_append_bucket(inst, stream, thisfilter,
 				buckets_out, NULL, 0, &consumed,
 				php_stream_is_persistent(stream)) != SUCCESS) {
diff --git a/ext/standard/tests/filters/gh22360.phpt b/ext/standard/tests/filters/gh22360.phpt
new file mode 100644
index 00000000000..b23483b22b9
--- /dev/null
+++ b/ext/standard/tests/filters/gh22360.phpt
@@ -0,0 +1,24 @@
+--TEST--
+GH-22360 (convert.base64-encode emits padding on incremental flush)
+--FILE--
+<?php
+$file = __DIR__ . '/gh22360.tmp';
+$fp = fopen($file, 'w');
+stream_filter_append($fp, 'convert.base64-encode', STREAM_FILTER_WRITE);
+
+fwrite($fp, "ab");
+fflush($fp);
+fwrite($fp, "c");
+fflush($fp);
+fclose($fp);
+
+var_dump(file_get_contents($file));
+echo base64_encode("abc"), PHP_EOL;
+?>
+--CLEAN--
+<?php
+@unlink(__DIR__ . '/gh22360.tmp');
+?>
+--EXPECT--
+string(4) "YWJj"
+YWJj