Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpKernel] [DataCollector] Avoid Catchable Fatal Error: Object of class __PHP_Incomplete_Class could not be converted to string #17586

Closed
@yceruto

Description

@yceruto

While the user doesn't delete the session data or clear cache of the browser, this exception occurrs when I access to panel profile > "Request/Response" > tab "Session" > "Session Attributes" and exists a serialized object (in session) whose class doesn't exist. Here has threw the exception:

//Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter.php line #76
return (string) $value; //instance of __PHP_Incomplete_Class

Since in these cases is_object will return false, I propose to add the following code to avoid the exception and display a readable value to the user:

// Special case of object
if ($value instanceof \__PHP_Incomplete_Class) {
    $array = new \ArrayObject($value);

    return sprintf('__PHP_Incomplete_Class(%s)', $array['__PHP_Incomplete_Class_Name']);
}

Result:

Session Attributes

Attribute Value
name __PHP_Incomplete_Class(AppBundle\Model\DeletedClass)

If they agree, I can create a PR to fix it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions