Skip to content

ZipArchive is missing the NOT_SERIALIZABLE flag #21682

Closed

Description

@arnaud-lb

Description

The following code:

$a = new ZipArchive();
var_dump($a->open('test.zip', ZipArchive::CREATE));
var_dump($a->addFromString('test.php', '<?php'));
var_dump($a->numFiles);

$a = unserialize(serialize($a));
echo "# Num files after serialize:\n";
var_dump($a->numFiles);

Resulted in this output:

[...]
# Num files after serialize:
int(0)

But I expected this output instead:

Fatal error: Uncaught Exception: Serialization of 'ZipArchive' is not allowed

Found by @nicolas-grekas

PHP Version

*

Operating System

No response

Activity

  1. added 3 commits that reference this issue on Apr 9, 2026
    f664bbd
  2. added a commit that references this issue on Jun 5, 2026
    8fe20ce
  3. added a commit that references this issue on Jun 25, 2026
    4e1edc7
  4. added a commit that references this issue on Jun 26, 2026
    adc5f8d
  5. added a commit that references this issue on Jun 30, 2026
    dcb3523
  6. added a commit that references this issue on Jul 30, 2026
    4782ec5
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