[php-src] Issue #21705: `ZipArchive::getFromIndex()` ignores `ZipArchive::FL_UNCHANGED` for deleted entries
| From: | LamentXU123 | Date: | Fri, 10 Apr 2026 09:19:38 +0000 |
| Subject: | [php-src] Issue #21705: `ZipArchive::getFromIndex()` ignores `ZipArchive::FL_UNCHANGED` for deleted entries | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251936@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/21705
Author: LamentXU123
### Description
The following code:
```php
<?php
$name = __DIR__ . '/test.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();
@unlink($name);
?>
```
Resulted in this output:
```
string(3) "bar"
bool(false)
```
But I expected this output instead:
```
string(3) "bar"
string(3) "bar"
```
Seems like
ZipArchive::getFromIndex() accepts a $flags argument, but in
ext/zip/php_zip.c the index lookup path does not pass those flags to
zip_stat_index(). getFromName() works, but getFromIndex()
does not honor FL_UNCHANGED.
### PHP Version
```plain
all supported version
```
### Operating System
_No response_