Vichuploaderbundle: Web profiler template missing

Created on 9 Dec 2019  路  20Comments  路  Source: dustin10/VichUploaderBundle

BC Break Report

My web profiler toolbar won't load and having the following records in the log:

[2019-12-09 10:01:35] request.CRITICAL: Uncaught PHP Exception UnexpectedValueException: "The profiler template "@VichUploader/Collector/mapping_collector.html.twig" for data collector "vich_uploader.mapping_collector" does not exist." at /vendor/symfony/web-profiler-bundle/Profiler/TemplateManager.php line 89 {"exception":"[object] (UnexpectedValueException(code: 0): The profiler template \"@VichUploader/Collector/mapping_collector.html.twig\" for data collector \"vich_uploader.mapping_collector\" does not exist. at /vendor/symfony/web-profiler-bundle/Profiler/TemplateManager.php:89)"} []

Possibly related to: #1067

| Q | A
|------------ | ------
| BC Break | yes
| Version | 1.12.1

Summary

Looks like the profiler can't find the required template.

Previous behavior

The profiler toolbar loaded correctly.

Current behavior

The profiler toolbar says: "An error occurred while loading the web debug toolbar."

How to reproduce

Enable the web profiler bundle and show the toolbar while having the latest version of VichUploaderBundle.

EDIT: Symfony 4.4.1 (env: dev, debug: true)

Support

Most helpful comment

I don't think requiring components we don't actually use is a good idea.
A better solution could be adding a note in documentation to warn users about this possible problem.

All 20 comments

Symfony version?

Sorry, Symfony 4.4.1 (env: dev, debug: true)

Sorry, I can't reproduce

Works properly with VichUploaderBundle version 1.11.0. But when I upgrade to 1.12.1 the debug toolbar won't load, and the above mentioned log entry is being created.

Can you confirm that you enabled and see the profiler toolbar correctly?

Schermata da 2019-12-09 10-32-22

My local config in /config/packages/dev/web_profiler.yaml

web_profiler:
    toolbar: true
    intercept_redirects: false

framework:
    profiler: { only_exceptions: false }

You can remove intercept_redirects: false (it's deprecated), but it's fine

Using PHP 7.3.11, but that's probably does not matters. Removed the intercept_redirects line but no difference. Here is what I see:

Screenshot from 2019-12-09 10-36-39

Anyways, if no one can reproduce it, I will stick to the previous version until I find out what causing the trouble.

It's weird, these are changes between versions, I can't spot anything related to profiler:

https://github.com/dustin10/VichUploaderBundle/compare/1.11.0...1.12.1

My suspicion is that it has to do something with moving config files out from Resources folder. Maybe a relative path was used somewhere to define the template and this move made the path inaccessible. The only thing that bothers me is why I'm the only one affected. I don't remember configuring anything differently regarding the profiler, but eventually will find out. Maybe somebody else will report it too, we'll know more then. Thanks for your time to looking into it!

That config files are meant for others bundle to be configured with VichUploaderBundle, not for VichUploaderBundle itself

One addition to the above, it's not just the toolbar that crashed. Here is another error message I see on the pages where I have VichUploader installed.

[2019-12-09 15:06:31] request.CRITICAL: Uncaught PHP Exception Twig\Error\LoaderError: "There are no registered paths for namespace "VichUploader"." at /vendor/easycorp/easyadmin-bundle/src/Resources/views/default/includes/_delete_form.html.twig line 2 {"exception":"[object] (Twig\Error\LoaderError(code: 0): There are no registered paths for namespace \"VichUploader\". at /vendor/easycorp/easyadmin-bundle/src/Resources/views/default/includes/_delete_form.html.twig:2)"} []

It's a returning element that might be the key to solve this mistery; No registered paths for namespace VichUploader. I also noticed in my IDE that while using version 1.11.0 and pressing @ the hinting dropdown suggests @VichUploader (and the files in the bundle) while in the new version that's not the case. Like the bundle is not aware of some files, it does not registers those classes properly. This explains some things though, the problem appears when something referencing to @VichUploader namespace (Web profiler, EasyAdminBundle, etc...) They won't find what they are looking for. Might be a composer thing? Again, I have no clue why it's just me...

I can confirm the issue, 1.11 is working, 1.12 not. Same error. Sf 4.4.1

Workaround; if you register the namespace yourself it seems to be working. I had to add the following line to my projects config:

config/packages/twig.yaml

twig:
    paths:
        '%kernel.project_dir%/vendor/vich/uploader-bundle/templates': VichUploader

I'm sure this can be done in the vendor bundle as well, so users don't have to do it manually.

I just created an empty project with Symfony 4.4 (starting from website-skeleton), installed bundle and configured a mapped entity.
It just works as expected, without any further Twig configuration.

Found the issue on my side: because of another lib, some symfony bundles weren't updated to 4.4, especially the framework-bundle and twig-bundle :/

Now all bundles are 4.4 and it works with 1.12!

That's likely the same problem for other users.
I'm closing this, if someone has a valid way to reproduce problem, feel free to re-open

Thank you @gharlan, that was it. I had symfony/validator package set to 4.3. It kept back some other packages from updating, so when I did a manual update, the issue was solved. Here is the log for the reference, one (ore more) of this caused the issue:

  - Updating symfony/service-contracts (v1.1.8 => v2.0.1): Loading from cache
  - Updating symfony/security-bundle (v4.3.9 => v4.4.1): Loading from cache
  - Updating symfony/translation-contracts (v1.1.7 => v2.0.1): Loading from cache
  - Updating symfony/validator (v4.3.0 => v4.4.1): Loading from cache
  - Updating symfony/twig-bundle (v4.3.9 => v4.4.1): Loading from cache
  - Updating symfony/framework-bundle (v4.3.9 => v4.4.1): Loading from cache
  - Updating symfony/web-profiler-bundle (v4.3.9 => v4.4.1): Loading from cache
  - Updating symfony/doctrine-bridge (v4.3.9 => v4.4.1): Loading from cache

@garak Please consider to update the project dependencies reflecting to this, that would make sure nobody gets into this situation again.

EDIT: Also my workaround works with older versions as well, that could be a possible solution if setting these dependencies is not possible.

I don't think requiring components we don't actually use is a good idea.
A better solution could be adding a note in documentation to warn users about this possible problem.

same error in version": "1.13.1", back to "version": "1.11.0" fix error
Symfony 4.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

petrjirasek picture petrjirasek  路  7Comments

Marcelo-Petrucelli picture Marcelo-Petrucelli  路  3Comments

Propscode picture Propscode  路  4Comments

manguecreative picture manguecreative  路  4Comments

eved42 picture eved42  路  7Comments