symfony / demo

Symfony Demo Application
https://symfony.com/
MIT License
2.47k stars 1.61k forks source link

Don't use Twig CodeExtension helpers outside of a profiler panel #1455

Closed GromNaN closed 11 months ago

GromNaN commented 11 months ago

The CodeExtension Twig extension moved to the WebProfilerBundle https://github.com/symfony/symfony/pull/52483.

This extension should only be used for debugging tools code that is never executed in a production environment.

This demo uses the format_file helper even in prod environment. https://github.com/symfony/demo/blob/206f0c9aab07cdc9f7437640b12947d35e9d5e72/templates/debug/source_code.html.twig#L33

Even if it's very convenient and specific to this demo, we'd have to find another solution.

Demo needs to adjust, we don't want to support such use cases. https://github.com/symfony/symfony/pull/52531#issuecomment-1805373042

stof commented 11 months ago

This demo could create its own filter demo_format_file copying the implementation from the core if needed, with a big warning on that class telling that you should not actually deploy this in a production project. This should go in the existing SourceCodeExtension of the demo.

GromNaN commented 11 months ago

I added the helper to the existing SourceCodeExtension, which already has a warning comment. https://github.com/symfony/demo/pull/1456