contao / core-bundle

[READ-ONLY] Contao Core Bundle
GNU Lesser General Public License v3.0
123 stars 58 forks source link

[PHP Fatal Error] Argument passed to FragmentRegistry::get() must be of the type string, object given #1708

Closed clemensfreitag-dev closed 4 years ago

clemensfreitag-dev commented 4 years ago

Disclaimer

This is my very first issue on the Contao project ;)

Affected version(s)

Contao: Contao 4.8.4 installed with Contao Manager PHP: 7.3.11-1+0~20191026.48+debian9~1.gbpf71ca0

Description

After a clean installation of Contao and some configurations on the backend, I observe the following PHP fatal error in the Apache logs on all most every frontend access:

[php7:error] [pid 26793] [client [CROP]] PHP Fatal error: Uncaught Symfony\\Component\\Debug\\Exception\\FatalThrowableError: Argument 1 passed to Contao\\CoreBundle\\Fragment\\FragmentRegistry::get() must be of the type string, object given, called in [CROP]/contao4-dev/vendor/contao/core-bundle/src/HttpKernel/ControllerResolver.php on line 43 in [CROP]/contao4-dev/vendor/contao/core-bundle/src/Fragment/FragmentRegistry.php:54\nStack trace:\n#0 [CROP]/contao4-dev/vendor/contao/core-bundle/src/HttpKernel/ControllerResolver.php(43): Contao\\CoreBundle\\Fragment\\FragmentRegistry->get(Object(Closure))\n#1 [CROP]/contao4-dev/vendor/symfony/http-kernel/HttpKernel.php(134): Contao\\CoreBundle\\HttpKernel\\ControllerResolver->getController(Object(Symfony\\Component\\HttpFoundation\\Request))\n#2 [CROP]/contao4-dev/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 2)\n# in [CROP]/contao4-dev/vendor/contao/core-bundle/src/Fragment/FragmentRegistry.php on line 54, referer: [CROP]/home.html (host-related data replaced with [CROP])

The same issue is also reported here but I didn't identified any bug related on GitHub so far: https://community.contao.org/de/showthread.php?75959-Fehler-nach-Update-von-4-7-zu-4-8-3

Briefly looking into the source of the mentioned ControllerResolver.php:

    public function getController(Request $request)
    {
        if ($request->attributes->has('_controller')) {
            $fragmentConfig = $this->registry->get($request->attributes->get('_controller'));

$request->attributes->get('_controller') seems to return an object instead of a string what the called get() would expect.

How to reproduce

I assume it's not related to my server configuration, so I assume it's reproducable with the mentioned Contao+PHP setup.

xchs commented 4 years ago

Please update to Contao 4.8.5 first.

BTW: Use the issue tracker of the Contao monorepo to report new issues in Contao (however, the issue can now also be moved by the project owner instead).

clemensfreitag-dev commented 4 years ago

created https://github.com/contao/contao/issues/993, so this one is a duplicate now.

xchs commented 4 years ago

Like I already said, the ticket could have been moved accordingly by the project owner. So you didn't have to create a new one.

But no matter.