|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: sb at vestergaardcompany dot com
New email:
PHP Version: OS:


 [2016-07-12 13:34 UTC] sb at vestergaardcompany dot com
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:
$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}


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-12 15:22 UTC]
-Status: Open +Status: Duplicate
 [2016-07-12 15:22 UTC]
Already fixed with bug #72581.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Dec 03 20:05:54 2022 UTC