Hello, Resources cannot be serialized. This is mentionned on https://www.php.net/manual/en/function.serialize.php , but one can easily miss it. The information does not seem to appear on https://www.php.net/manual/en/language.oop5.serialization.php and https://www.php.net/manual/en/language.types.resource.php
And nowhere does it says what happens if you serialize an object with a resource in a property. Now most resources are replaced by classes in the recent versions of PHP. Because of this, it is advised to replace tests like (is_resource($object->res)) with ($object->res !== FALSE). So, I tried to do this in my application with LDAP connections, which will be objects in PHP 8.1. And the application broke, because when unserializing from session an object containting an LDAP connection, the property is set to int(0). So is_resource() and !== FALSE will not have the same result. I cannot find any documentation page mentionning that resources are turned into int(0) upon serialization. It seems to be consistent accross versions: https://3v4l.org/BHtAh But what will happen when LDAP connections are turned into objects in 8.1? Will they also become int(0) upon serialization or will they behave in an other way? I could not find a case of resource that became an object and is allowed on 3v4l to test this. There is no LDAP or CURL in there. Côme -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php