Fosuserbundle: error on login page Call to a member function has() on null

Created on 20 Feb 2018  路  8Comments  路  Source: FriendsOfSymfony/FOSUserBundle

I just made a composer update and have now a problem I can't resolve.
In my composer.json I have "friendsofsymfony/user-bundle": "~2.0", and the version of fosUser is v2.1.1 (with symfony 2.8)

I overrided the login and login_content.html.twig, but the structure is exactly the same as the original. I also overrided the securityController, but I didn't redefined the loginAction.

I have an exception on login page : Call to a member function has() on null

The stacktrace is as follows :

in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php at line 184  -

         */
        public function render($view, array $parameters = array(), Response $response = null)
        {
            if ($this->container->has('templating')) {
                return $this->container->get('templating')->renderResponse($view, $parameters, $response);
            }

at Controller ->render ('@FOSUser/Security/login.html.twig', array('last_username' => 'felix', 'error' => null, 'csrf_token' => 'lb1EhD4hiVtgohonlic2Q6OcnChpSvrQXDVdtCYtv5k'))
in vendor/friendsofsymfony/user-bundle/Controller/SecurityController.php at line 98  +
at SecurityController ->renderLogin (array('last_username' => 'felix', 'error' => null, 'csrf_token' => 'lb1EhD4hiVtgohonlic2Q6OcnChpSvrQXDVdtCYtv5k'))
in vendor/friendsofsymfony/user-bundle/Controller/SecurityController.php at line 74  +
at SecurityController ->loginAction (object(Request))
in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php at line 135  +
at HttpKernel ->handleRaw (object(Request), '1')
in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php at line 57  +
at HttpKernel ->handle (object(Request), '1', true)
in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php at line 67  +
at ContainerAwareHttpKernel ->handle (object(Request), '1', true)
in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php at line 183  +
at Kernel ->handle (object(Request))
in web/app_dev.php at line 36  +

As it used to work perfectly before, I don't know if the problem is mine or not.

Most helpful comment

I opened a PR with a fix. Can you try my patch (I don't have a Symfony 2.8 project anymore)

All 8 comments

I have exactly the same issue :

I have modified my composer.json to use "~2.0.0" instead of "~2.0" temporary until we have a fix.

[1] Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function has() on null
    at n/a
        in C:\wamp64\www\sd-bugtrapp\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\Controller.php line 184

    at Symfony\Bundle\FrameworkBundle\Controller\Controller->render('@FOSUser/Security/login.html.twig', array('last_username' => null, 'error' => null, 'csrf_token' => 'aPT4Bcm-bmeUsi1fRP--NL0pBb1mUp0E2OgP5tXPDIE'))
        in C:\wamp64\www\sd-bugtrapp\vendor\friendsofsymfony\user-bundle\Controller\SecurityController.php line 98

    at FOS\UserBundle\Controller\SecurityController->renderLogin(array('last_username' => null, 'error' => null, 'csrf_token' => 'aPT4Bcm-bmeUsi1fRP--NL0pBb1mUp0E2OgP5tXPDIE'))
        in C:\wamp64\www\sd-bugtrapp\vendor\friendsofsymfony\user-bundle\Controller\SecurityController.php line 74

    at FOS\UserBundle\Controller\SecurityController->loginAction(object(Request))
        in C:\wamp64\www\sd-bugtrapp\app\bootstrap.php.cache line 3262

    at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
        in C:\wamp64\www\sd-bugtrapp\app\bootstrap.php.cache line 3221

    at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
        in C:\wamp64\www\sd-bugtrapp\app\bootstrap.php.cache line 3375

    at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
        in C:\wamp64\www\sd-bugtrapp\app\bootstrap.php.cache line 2575

    at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
        in C:\wamp64\www\sd-bugtrapp\web\app_dev.php line 29

looks like a duplicate of #2737

Same issue here.

Unable to override FOS Controllers anymore.

I opened a PR with a fix. Can you try my patch (I don't have a Symfony 2.8 project anymore)

I'm testing it right now !

Thanks for the PR @stof 馃憤

Thanks a lot @stof, it works perfect now with your PR. Sorry it took me sometimes to configure composer so that it accepts your branch fix-controllers. It works well now on "friendsofsymfony/user-bundle": "~2.0@dev".

@fecou : For your information, next time you can do this :

"friendsofsymfony/user-bundle": "dev-<receivingBranchOfThePR>#CommitHash",

Exemple in this case : "friendsofsymfony/user-bundle": "dev-master#00c366ecdc2dfd3807d7a49424e66a872fc73850",

When it will be in prod?

Was this page helpful?
0 / 5 - 0 ratings