Bug #17760
closedUnserialized objects not debugged properly
0%
Description
This is related to bug #17685 "t3lib_div::view_array() can not show objects". The bug fix proposed by Michael is insufficient with PHP 5.2.x.
In short, when an object is unserialized and its class definition has not been included, PHP makes it into an Incomplete Class object. When such an object is passed to is_object() the result is false rather than true.
So it fails the is_object() test and is cast to string by the t3lib_div::view_array() resulting in a fatal error. Although PHP says that this error is catchable, I couldn't manage to catch it using a try/catch construct. So I added additional tests using gettype(), altghough use of the latter is not recommended.
I also introduced a test to check for the existence of the __toString method, which makes it possible to use the object's proper output if present, rather than just outputting "Object" and the result of get_class().
While I was at it, I replaced the while/each construct by a foreach loop.
(issue imported from #M6663)
Files