Re: [PHP-DEV] Resources and object resources

2021-08-31 Thread Nikita Popov
On Tue, Aug 31, 2021 at 4:16 PM Côme Chilliet <
come.chill...@fusiondirectory.org> wrote:

> Le Tue, 31 Aug 2021 15:56:42 +0200,
> Côme Chilliet  a écrit :
> > 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.
>
> Quick followup on this, I found a case that can be tested on 3v4l:
> https://3v4l.org/EKFP0
>
> -> Fatal error: Uncaught Exception: Serialization of 'XMLParser' is not
> allowed
> in /in/EKFP0:13
>
> So it seems objects of this kind throw when serialized (I hope they all do
> that).


Unless we made a mistake somewhere, yes, all "resource-like" objects are
not serializable and will throw an attempted serialization or
unserialization.


> It is not clear to me how that behaves with session, will it throw as
> soon as affected to $_SESSION, or at the end of the request?
>

Storing it in $_SESSION temporarily should work fine, it will only throw
when the session is serialized.

Regards,
Nikita


Re: [PHP-DEV] Resources and object resources

2021-08-31 Thread Côme Chilliet
Le Tue, 31 Aug 2021 15:56:42 +0200,
Côme Chilliet  a écrit :
> 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.

Quick followup on this, I found a case that can be tested on 3v4l:
https://3v4l.org/EKFP0

-> Fatal error: Uncaught Exception: Serialization of 'XMLParser' is not allowed
in /in/EKFP0:13

So it seems objects of this kind throw when serialized (I hope they all do
that). It is not clear to me how that behaves with session, will it throw as
soon as affected to $_SESSION, or at the end of the request?

https://www.php.net/manual/en/class.xmlparser.php -> does fully opaque implies
non serializable?

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php