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
 [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

Pull Requests

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: Thu Nov 21 12:01:29 2024 UTC