Skip to content

ZipArchive deletes zip file with no contents and doesn't update stat cache #8781

Closed
@timint

Description

@timint

Description

There is a problem with ZipArchive deleting empty archives without notice upon successful close. And statcache not updated.

<?php
    $tmp_file = tempnam(sys_get_temp_dir(), '');
    var_dump(is_file($tmp_file)); // returns true

    $zip = new ZipArchive;
    $zip->open($tmp_file, ZipArchive::OVERWRITE);
    $zip->close(); // returns true

    var_dump(is_file($tmp_file)); // returns true
    var_dump(file_get_contents($tmp_file)); // returns error file does not exist

I expected the defined file to remain. If I can't count on that I expected the statcache to be updated.

PHP Version

PHP 8.1.6

Operating System

Windows 11 x64

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions