Skip to content

ZipArchive::getFromIndex() ignores ZipArchive::FL_UNCHANGED for deleted entries #21705

Closed

Description

@LamentXU123

Description

The following code:

<?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)); // the ZipArchive::FL_UNCHANGED is ignored

$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

all supported version

Operating System

No response

Activity

  1. added 2 commits that reference this issue on Jul 3, 2026
    d35ade5
    bc3a7c7
  2. added a commit that references this issue on Jul 3, 2026
    041ef84
  3. added a commit that references this issue on Jul 3, 2026
    c0f01b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions