symfony/symfony — Issue #2751: [FrameworkBundle] [cache:warmup] 
Author: jonathaningram
Created: 2011-11-30 04:52:39+00:00
State: open

OK this is a tricky one because there are three repos involved: `TwigBundle`, `FrameworkBundle` and `Twig`. I chose `FrameworkBundle` since it seems to be an issue with `--no-debug`.

First, here is the stack (note: command is prod env with no-debug):

```
$ ./app/console --env=prod cache:warmup -v --no-debug

Warming up the cache
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 17837 bytes) in /Users/me/myapp/vendor/twig/lib/Twig/Compiler.php on line 132
PHP Stack trace:
PHP 1. {main}() /Users/me/myapp/app/console:0
PHP 2. Symfony\Component\Console\Application->run() /Users/me/myapp/app/console:16
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /Users/me/myapp/vendor/symfony/src/Symfony/Component/Console/Application.php:105
PHP 4. Symfony\Component\Console\Application->doRun() /Users/me/myapp/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75
PHP 5. Symfony\Component\Console\Command\Command->run() /Users/me/myapp/vendor/symfony/src/Symfony/Component/Console/Application.php:188
PHP 6. Symfony\Bundle\FrameworkBundle\Command\CacheWarmupCommand->execute() /Users/me/myapp/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:227
PHP 7. Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() /Users/me/myapp/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php:50
PHP 8. Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheCacheWarmer->warmUp() /Users/me/myapp/vendor/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:46
PHP 9. Twig_Environment->loadTemplate() /Users/me/myapp/vendor/symfony/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php:62
PHP 10. Twig_Environment->compileSource() /Users/me/myapp/vendor/twig/lib/Twig/Environment.php:317
PHP 11. Twig_Environment->compile() /Users/me/myapp/vendor/twig/lib/Twig/Environment.php:523
PHP 12. Twig_Compiler->compile() /Users/me/myapp/vendor/twig/lib/Twig/Environment.php:509
PHP 13. Twig_Node_Module->compile() /Users/me/myapp/vendor/twig/lib/Twig/Compiler.php:70
PHP 14. Twig_Node_Module->compileTemplate() /Users/me/myapp/vendor/twig/lib/Twig/Node/Module.php:33
PHP 15. Twig_Compiler->subcompile() /Users/me/myapp/vendor/twig/lib/Twig/Node/Module.php:52
PHP 16. Twig_Node->compile() /Users/me/myapp/vendor/twig/lib/Twig/Compiler.php:81
PHP 17. Twig_Node->compile() /Users/me/myapp/vendor/twig/lib/Twig/Node.php:106
PHP 18. Twig_Node_Block->compile() /Users/me/myapp/vendor/twig/lib/Twig/Node.php:106
PHP 19. Twig_Compiler->subcompile() /Users/me/myapp/vendor/twig/lib/Twig/Node/Block.php:40
PHP 20. Twig_Node->compile() /Users/me/myapp/vendor/twig/lib/Twig/Compiler.php:81
PHP 21. Twig_Node_Text->compile() /Users/me/myapp/vendor/twig/lib/Twig/Node.php:106
PHP 22. Twig_Compiler->string() /Users/me/myapp/vendor/twig/lib/Twig/Node/Text.php:36
```

Now, run the command again without `--no-debug` (I also completely removed my `prod` cache) and voila, no error.

Let me paste some code from my templates.

My core bundle `layout.html.twig`:

```twig
{% block stylesheets %}

{% endblock %}

{% block javascripts %}

{% endblock %}
```
Remove the `stylesheets` and `javascripts` block, or rename it to `whatever` and run the command again (with `--no-debug` and clearing cache) and voila, no error.

So the question is: can you not have blocks named as such (apart from the obvious that there are tags used for assetic with such names)? If not, then why does it work in dev but not prod?

And also if not, why does it not fail when you remove `--no-debug`?