php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72584 Exception::__toString() fails after unserialize().
Submitted: 2016-07-12 13:34 UTC Modified: 2016-07-12 15:22 UTC
From: sb at vestergaardcompany dot com Assigned:
Status: Duplicate Package: Class/Object related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
3 + 9 = ?
Subscribe to this entry?

 
 [2016-07-12 13:34 UTC] sb at vestergaardcompany dot com
Description:
------------
It seems that if an Exception object is serialized and unserialized, the resulting object does not have the private "previous" property set correctly.

Invoking the __toString method on the resulting object generates a PHP Notice.



Test script:
---------------
<?php
$e1 = new Exception("Test");
$e2 = unserialize( serialize( $e1 ) );
echo $e2->__toString() . "\n";
?>


Expected result:
----------------
exception 'Exception' with message 'Test' in /home/...php:2
Stack trace:
#0 {main}


Actual result:
--------------
PHP Notice:  Undefined property: Exception::$previous in /home/...php on line 4
PHP Stack trace:
PHP   1. {main}() /home/...php:0
PHP   2. Exception->__toString() /home/...php:4
exception 'Exception' with message 'Test' in /home/...php:2
Stack trace:
#0 {main}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-12 15:22 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 [2016-07-12 15:22 UTC] requinix@php.net
Already fixed with bug #72581.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 19:01:31 2024 UTC