mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 18:36:53 +00:00
fixed edge case in the method cache for Twig attributes
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
* 1.33.2 (2017-XX-XX)
|
* 1.33.2 (2017-XX-XX)
|
||||||
|
|
||||||
* n/a
|
* fixed edge case in the method cache for Twig attributes
|
||||||
|
|
||||||
* 1.33.1 (2017-04-18)
|
* 1.33.1 (2017-04-18)
|
||||||
|
|
||||||
|
|||||||
@@ -627,11 +627,14 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($cache[$name])) {
|
// skip get() and is() methods (in which case, $name is empty)
|
||||||
$cache[$name] = $method;
|
if ($name) {
|
||||||
}
|
if (!isset($cache[$name])) {
|
||||||
if (!isset($cache[$lcName])) {
|
$cache[$name] = $method;
|
||||||
$cache[$lcName] = $method;
|
}
|
||||||
|
if (!isset($cache[$lcName])) {
|
||||||
|
$cache[$lcName] = $method;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self::$cache[$class] = $cache;
|
self::$cache[$class] = $cache;
|
||||||
|
|||||||
@@ -424,6 +424,19 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
return $tests;
|
return $tests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Twig_Error_Runtime
|
||||||
|
*/
|
||||||
|
public function testGetIsMethods()
|
||||||
|
{
|
||||||
|
$getIsObject = new Twig_TemplateGetIsMethods();
|
||||||
|
$template = new Twig_TemplateTest(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array('strict_variables' => true)));
|
||||||
|
// first time should not create a cache for "get"
|
||||||
|
$this->assertNull($template->getAttribute($getIsObject, 'get'));
|
||||||
|
// 0 should be in the method cache now, so this should fail
|
||||||
|
$this->assertNull($template->getAttribute($getIsObject, 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Twig_TemplateTest extends Twig_Template
|
class Twig_TemplateTest extends Twig_Template
|
||||||
@@ -669,6 +682,17 @@ class Twig_TemplateMethodObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Twig_TemplateGetIsMethods
|
||||||
|
{
|
||||||
|
public function get()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Twig_TemplateMethodAndPropObject
|
class Twig_TemplateMethodAndPropObject
|
||||||
{
|
{
|
||||||
private $a = 'a_prop';
|
private $a = 'a_prop';
|
||||||
|
|||||||
Reference in New Issue
Block a user