Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vendor updates broke FOS User Bundle with "Call to a member function has() on a non-object"

I updated my vendors for a Symfony 2.8 project and suddenly the login page isn't loading – instead I get this:

Error: Call to a member function has() on a non-object in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php at line 184

"name": "hazardlog",
"license": "proprietary",
"type": "project",
"autoload": {
    "psr-4": {
        "": "src/"
    },
    "classmap": [
        "app/AppKernel.php",
        "app/AppCache.php"
    ]
},
"repositories": [
    {
        "type": "package",
        "package": {
            "name": "jquery/jquery",
            "version": "1.11.1",
            "dist": {
                "url": "https://code.jquery.com/jquery-1.11.1.js",
                "type": "file"
            }
        }
    }
],
"require": {
    "php": ">=5.3.9",
    "symfony/symfony": "2.8.*",
    "doctrine/orm": "^2.4.8",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "braincrafted/bootstrap-bundle": "~2.0",
    "twbs/bootstrap": "3.0.*",
    "jquery/jquery":  "1.11.*",
    "hwi/oauth-bundle": "^0.5.0",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "stephanecollot/datetimepicker-bundle": "dev-master"
},
"require-dev": {
    "sensio/generator-bundle": "~3.0",
    "symfony/phpunit-bridge": "~2.7"
},
"scripts": {
    "symfony-scripts": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ],
    "post-install-cmd": [
        "@symfony-scripts"
    ],
    "post-update-cmd": [
        "@symfony-scripts"
    ]
},
"config": {
    "bin-dir": "bin"
},
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "symfony-assets-install": "relative",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    }
}
like image 727
Matt Welander Avatar asked Mar 08 '23 04:03

Matt Welander


1 Answers

I have seen this sort of question several times but I could not find one with an accepted answer and explanation. So here goes.

The basic problem lies with:

"friendsofsymfony/user-bundle": "~2.0@dev",

Back when Symfony 2.8/3.0 was first released, the stable 1.x version of FOSUserBundle no longer worked. The 2.x version has been in development for years with no actual road map in sight for when it would be stabilized. So the development branch was hacked up to get it working. And folks had no choice but to use it which of course is dangerous because you never know when a development change might in fact break your code.

Time went by and eventually a stable 2.x version of the FOSUserBundle was released. However, quite a few developers never got around to updating their dependencies and continued to use the master branch.

Fast forward to the present. The release of Symfony 4 has now triggered a fair amount of development in the master branch. Development which is introducing breaking changes to existing 2.8 (and probably 3.0) code.

The bottom line is to use a stable branch with:

"friendsofsymfony/user-bundle": "~2.0",

followed by a composer update.

like image 145
Cerad Avatar answered Apr 28 '23 19:04

Cerad