Skip to content

Make the Imagick classes not serializable - #800

Open
nicolas-grekas wants to merge 1 commit into
Imagick:masterfrom
nicolas-grekas:not-serializable
Open

nicolas-grekas wants to merge 1 commit into
Imagick:masterfrom
nicolas-grekas:not-serializable

Conversation

@nicolas-grekas

@nicolas-grekas nicolas-grekas commented Sep 29, 2026 •

Copy link
Copy Markdown

serialize() loses the images, pixels and drawings of these objects, and unserialize() silently creates empty ones instead.

This flags the classes as not serializable, so that both throw, like for PDO or CurlHandle, and like php/php-src#21694 did for XMLWriter, XMLReader, SNMP and tidy. Serializers that honor the flag, like symfony/php-ext-deepclone, then reject them too. Before PHP 8.1, which has no such flag, they get the handlers that deny serialization instead.

@nicolas-grekas

Copy link
Copy Markdown
Author

PR updated: before PHP 8.1, the classes now get the handlers that deny serialization, as suggested in phpredis/phpredis#2938, and the test runs on those versions too.

serialize() lost their images, pixels and drawings, and unserialize()
created empty objects instead. Both now throw: from PHP 8.1 on through
the ZEND_ACC_NOT_SERIALIZABLE flag, and before through the
zend_class_(un)serialize_deny handlers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant