Symfony update from 4.2 to 4.3 caused Web Profiler to break
Asked Answered
C

3

3

I ran composer update and now am getting a slew of deprecation warnings:

> [2019-06-03 18:08:41] request.INFO: Matched route "_wdt".
> {"route":"_wdt","route_parameters":{"_route":"_wdt","_controller":"web_profiler.controller.profiler::toolbarAction","token":"9354bc"},"request_uri":"http://local
> host:8080/_wdt/9354bc","method":"GET"} [] [2019-06-03 18:08:42]
> request.CRITICAL: Uncaught PHP Exception Twig\Error\RuntimeError:
> "Impossible to access an attribute ("nb_errors") on a string variable
> ("O:39:"Symfony\Component\VarDumper\Cloner\Data":6:{s:45:"ymf
> ony\Component\VarDumper\Cloner\Data

The Web Profiler Toolbar is broken with this error:

An error occurred while loading the web debug toolbar.

And yet when I do bin/console --version I am getting:

Symfony 4.3.0 (env: dev, debug: true)

What gives? What about the composer.json file gives Composer the ability to update to 4.3 even?


Here is my current composer.json:

{
  "type": "project",
  "license": "proprietary",
  "require": {
    "php": "^7.1.3",
    "ext-iconv": "*",
    "doctrine/doctrine-migrations-bundle": "^2.0",
    "easycorp/easyadmin-bundle": "^1.17",
    "iio/libmergepdf": "~3.0",
    "ramsey/uuid": "^3.5",
    "sensio/framework-extra-bundle": "^5.1",
    "sensiolabs/security-checker": "^5.0",
    "simplisti/jasper-starter": "dev-master",
    "symfony/asset": "4.2.*",
    "symfony/console": "4.2.*",
    "symfony/dotenv": "4.2.*",
    "symfony/expression-language": "4.2.*",
    "symfony/flex": "^1.1",
    "symfony/form": "4.2.*",
    "symfony/framework-bundle": "4.2.*",
    "symfony/ldap": "^4.0",
    "symfony/monolog-bundle": "^3.3",
    "symfony/options-resolver": "^4.0",
    "symfony/orm-pack": "*",
    "symfony/process": "4.2.*",
    "symfony/security-bundle": "4.2.*",
    "symfony/swiftmailer-bundle": "^3.1",
    "symfony/yaml": "4.2.*"
  },
  "require-dev": {
    "doctrine/doctrine-fixtures-bundle": "^3.0",
    "phing/phing": "^2.14",
    "symfony/browser-kit": "^4.0",
    "symfony/css-selector": "^4.0",
    "symfony/debug": "^4.0",
    "symfony/debug-pack": "^1.0",
    "symfony/maker-bundle": "^1.7",
    "symfony/phpunit-bridge": "^4.0",
    "symfony/profiler-pack": "^1.0"
  },
  "config": {
    "preferred-install": {
      "*": "dist"
    },
    "sort-packages": true
  },
  "autoload": {
    "classmap": [
      "src/Legacy/"
    ],
    "psr-4": {
      "App\\": "src/"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "App\\Tests\\": "tests/"
    }
  },
  "replace": {
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php71": "*",
    "symfony/polyfill-php70": "*",
    "symfony/polyfill-php56": "*"
  },
  "scripts": {
    "auto-scripts": {
      "cache:clear": "symfony-cmd",
      "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd",
      "security-checker security:check": "script"
    },
    "post-install-cmd": [
      "@auto-scripts"
    ],
    "post-update-cmd": [
      "@auto-scripts"
    ]
  },
  "conflict": {
    "symfony/symfony": "*"
  },
  "extra": {
    "symfony": {
      "id": "01C3XNQSBGC1MSASSGCW6TKGXB",
      "allow-contrib": false
    }
  }
}
Crosswind answered 3/6, 2019 at 18:14 Comment(4)
What version did you update from? I made a quick test on a fresh 4.3 project without encountering these warnings.Receiver
4.2.9 on Friday...now somehow 4.3.0?!? Can you see anything obvious in my composer.json in OP?Crosswind
Bit of a mystery to say the least. I took a fresh 4.2.8 and ran composer update. As expected, I got 4.2.9. Ran update again and it stayed at 4.2.9. You do have some ^4.0's in your composer.json file. Mine does not. I seldom have much luck recovering from messed up composer.json files. Might consider installing a fresh 4.2.9 project then merge your additional dependencies into the out of the box composer.json.Receiver
Thats what I was thinking...thanks for confirming my hunch or assumption haha :)Crosswind
A
11

Open composer.json. Update all the 4.2 references to 4.3. You probably have symfony/web-profiler-bundle in there as 4.2 instead of 4.3. Save, then composer update.

Arelus answered 4/6, 2019 at 11:38 Comment(2)
Everything is pretty much 4.2.* not sure how 4.3.0 even got in there? I've deleted /vendor and composer install multiple times...can you see anything obvious in my composer.json added to OP?Crosswind
This solution worked for me. Thanks a bunch @afessler! I was upgrading from symfony version 4.2.* to 4.4.*. Before I ran the composer update script I only changed the "require" from 4.2.* to 4.4.*. Among other problems I faced, I also need to see the web profiler which was not showing. Following this instruction I had to change all references to 4.2.* to 4.4.* to get everything working again. I had to change use Symfony\Bridge\Doctrine\RegistryInterface; to use Doctrine\Common\Persistence\ManagerRegistry; for my repository classes as well with this upgrade.Educatory
T
0

It's a problem in vendor/symfony/web-profiler-bundle/Resources/views/Collector/form.html.twig

Trying to access collector.data.nb_errors, but collector.data is null.

Tendentious answered 4/6, 2019 at 10:17 Comment(2)
Did you found a solution? Got the same problem but have no clue what to do, to fix itPsychographer
@Psychographer the accepted comment worked for us.Tendentious
A
0

I'm a little bit late but if you want to keep symfony 4.2, you just have to replace all yours symfony's dependencies from "^4" to "4.2.*" in composer.json

For example, in your json you have "symfony/ldap": "^4.0", so when you ran composer show, you'll see that some dependencies where upgrade to 4.3 with a composer update.

Apocrypha answered 4/7, 2019 at 14:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.