diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 5194eaa0df0ea..e6965825d59c6 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -2788,7 +2788,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 0000000000000..41dabb2245105 --- /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-- +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-- + +--EXPECT-- +string(3) "bar" +string(3) "bar"