Matt Welander
Matt Welander

Reputation: 8548

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"
    }
}

Upvotes: 4

Views: 603

Answers (3)

LeavingTown
LeavingTown

Reputation: 13

had a problem like this here but solved,i just did the opposite of this. i had:

"friendsofsymfony/user-bundle": "^2.1",

in my composer.json file which give me a Call to a member function has() on null error to solve this i Actually add "@dev it became:

"friendsofsymfony/user-bundle": "^2.1@dev",

then updated my composer with :

composer update

Upvotes: 0

lsimonetti
lsimonetti

Reputation: 1482

For those using Symfony 3.2, it looks like version "~2.1" throws same error along with the OP's version "~2.0@dev".

This worked:

"friendsofsymfony/user-bundle": "2.0"

Keeping it at 2.0 did the trick for me.

Upvotes: 0

Cerad
Cerad

Reputation: 48865

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.

Upvotes: 7

Related Questions