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

Skip to content

Unserialize error in functional test with redirect and data collector enabled #28125

Closed
@jean-gui

Description

@jean-gui

Symfony version(s) affected: 3.4.13, 4.1.3

Description
There seems to be a bug in when functional testing an action under the following conditions:

  • the tested controller redirects to another action
  • browser client runs in insulated mode
  • data collector is enabled

When running the test, the following error is reported:

RuntimeException : OUTPUT:  ERROR OUTPUT: PHP Fatal error:  Uncaught unserialize(): Error at offset 1569 of 2589 bytes

/media/perso/my_project2/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:290

  thrown in Standard input code on line 14

 /media/perso/my_project2/vendor/symfony/browser-kit/Client.php:405
 /media/perso/my_project2/vendor/symfony/framework-bundle/Client.php:143
 /media/perso/my_project2/vendor/symfony/browser-kit/Client.php:349
 /media/perso/my_project2/vendor/symfony/browser-kit/Client.php:561
 /media/perso/my_project2/vendor/symfony/browser-kit/Client.php:369
 /media/perso/my_project2/tests/Controller/RedirectControllerTest.php:15

How to reproduce
A minimal project exposing the issue can be found at https://github.com/jean-gui/redirect-collector. Interesting files are:

Running PHPUnit will lead to the error mentioned above.

Possible Solution
In Symfony\Bundle\FrameworkBundle\Client, changing getScript() as shown below seems to fix the issue. I don't know if that has any negative side-effects.

protected function getScript($request)
    {
        $kernel = str_replace("'", "\\'", serialize($this->kernel));
        $request = str_replace("'", "\\'", serialize($request));
        $request = str_replace('\\\\', '\\\\\\', $request);
        ...

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions