removed template source code for generated template classes when debug is disabled

This commit is contained in:
Fabien Potencier
2016-10-05 11:24:21 -07:00
parent 75e4aa5eef
commit 7a047679ab
3 changed files with 14 additions and 1 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.26.1 (2016-XX-XX)
* removed template source code from generated template classes when debug is disabled
* fixed default implementation of Twig_Template::getDebugInfo() for better BC
* fixed regression on static calls for functions/filters/tests
+1 -1
View File
@@ -136,7 +136,7 @@ class Twig_Lexer implements Twig_LexerInterface
mb_internal_encoding($mbEncoding);
}
return new Twig_TokenStream($this->tokens, $this->filename, $code);
return new Twig_TokenStream($this->tokens, $this->filename, $this->env->isDebug() ? $code : '');
}
protected function lexData()
+12
View File
@@ -10,6 +10,18 @@
*/
class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase
{
public function testStreamSource()
{
$env = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock());
$lexer = new Twig_Lexer($env);
$env->disableDebug();
$this->assertSame('', $lexer->tokenize('foo')->getSource());
$env->enableDebug();
$this->assertSame('foo', $lexer->tokenize('foo')->getSource());
}
public function testNameLabelForTag()
{
$template = '{% § %}';