[php-src] master: Merge branch 'PHP-8.4' into PHP-8.5

Weilin Du <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Weilin Du (LamentXU123)
Date: 2026-07-03T14:24:22+08:00

Commit: https://github.com/php/php-src/commit/c0f01b346075978bcc26ae91759e5ed19354cb8f
Raw diff: https://github.com/php/php-src/commit/c0f01b346075978bcc26ae91759e5ed19354cb8f.diff

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  Fix GH-21705: ZipArchive::getFromIndex() ignores FL_UNCHANGED (#21706)

Changed paths:
  A  ext/zip/tests/bug_gh21705.phpt
  M  NEWS
  M  ext/zip/php_zip.c


Diff:

diff --git a/NEWS b/NEWS
index 3bd77e450600..d7a1758a7f2d 100644
--- a/NEWS
+++ b/NEWS
@@ -84,6 +84,10 @@ PHP                                                                        NEWS
   . Fixed behavior of Uri\WhatWg\Url wither methods with regards to empty
     opaque hosts. (kocsismate)
 
+- Zip:
+  . Fixed bug GH-21705 (ZipArchive::getFromIndex() ignores
+    ZipArchive::FL_UNCHANGED for deleted entries). (Weilin Du)
+
 02 Jul 2026, PHP 8.5.8
 
 - Core:
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 605d561ac7e4..fd339e4fe745 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -2891,7 +2891,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
 
 		ZIP_FROM_OBJECT(intern, self);
 
-		PHP_ZIP_STAT_INDEX(intern, index, 0, sb);
+		PHP_ZIP_STAT_INDEX(intern, index, flags, sb);
 	}
 
 	if (sb.size < 1) {
diff --git a/ext/zip/tests/bug_gh21705.phpt b/ext/zip/tests/bug_gh21705.phpt
new file mode 100644
index 000000000000..41dabb224510
--- /dev/null
+++ b/ext/zip/tests/bug_gh21705.phpt
@@ -0,0 +1,33 @@
+--TEST--
+ZipArchive::getFromIndex() honors FL_UNCHANGED for deleted entries
+--EXTENSIONS--
+zip
+--FILE--
+<?php
+$name = __DIR__ . '/bug_gh21705.zip';
+@unlink($name);
+$zip = new ZipArchive;
+$zip->open($name, ZipArchive::CREATE);
+$zip->addFromString('foo.txt', 'foo');
+$zip->addFromString('bar.txt', 'bar');
+$zip->close();
+
+$zip = new ZipArchive;
+$zip->open($name);
+
+$index = $zip->locateName('bar.txt');
+$zip->deleteName('bar.txt');
+
+var_dump($zip->getFromName('bar.txt', 0, ZipArchive::FL_UNCHANGED));
+var_dump($zip->getFromIndex($index, 0, ZipArchive::FL_UNCHANGED));
+
+$zip->close();
+?>
+--CLEAN--
+<?php
+$name = __DIR__ . '/bug_gh21705.zip';
+@unlink($name);
+?>
+--EXPECT--
+string(3) "bar"
+string(3) "bar"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.