Re: Re: Serializing exceptions
| From: | Nikita Popov | Date: | Tue, 28 Jul 2015 13:07:54 +0000 |
| Subject: | Re: Re: Serializing exceptions | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-87339@lists.php.net to get a copy of this message | ||
On Mon, Jul 27, 2015 at 9:08 AM, Stas Malyshev <smalyshev@gmail.com> wrote:
> Hi!
>
> Looking into some issue, I've discovered that, to my surprise,
> > Exceptions are serializable. Except that it doesn't always work of
> > course (e.g. see
> > http://stackoverflow.com/q/9747813/214196) because
> > exceptions contain backtraces, and those can contain non-serializable
> > objects. So in reality, you never know if you can serialize it or not.
> >
> > So, I wonder - would it be ok to make exceptions not serializable at
> > all? I think that would prevent major WTF factor when people try it and
> > it randomly fails.
> >
>
> Since discussion on this did not lead to a definite conclusion, but I did
> not hear from anybody that they need serialized exceptions, and we keep
> getting bug reports about exception serialization and various issues
> triggered by it, I propose this change:
> https://github.com/php/php-src/pull/1442
>
> Since it is kind of BC break (even though I assume it breaks something that
> needed not to be allowed in the first place) I'd like to merge it in 7.0.0.
> Please object if you think this should not be done and explain why.
> Otherwise I intend to merge it after a suitable wait and after adding
> necessary tests/docs.
>
-1 on this. If there is no technical problem with serializing the Exception
class itself, it should be possible to serialize it. It can always happen
that an object contains some not-serializable member, this is nothing
specific to exceptions. I don't see the point of this change.
Also, Christian Stoller's mail pointed out that Symfony uses serialized
exceptions.
Nikita