mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 19:06:40 +00:00
Fixed fetching of a property defined but not initialized in C extension, fixed #1337
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
* fixed the conversion of the special '0000-00-00 00:00' date
|
||||
* added an error message when trying to import an undefined block from a trait
|
||||
* fixed a C extension crash when accessing defined but uninitialized property.
|
||||
|
||||
* 1.15.0 (2013-12-06)
|
||||
|
||||
|
||||
+2
-4
@@ -324,10 +324,8 @@ zval *TWIG_PROPERTY(zval *object, zval *propname TSRMLS_DC)
|
||||
#else
|
||||
tmp = Z_OBJ_HT_P(object)->read_property(object, propname, BP_VAR_IS TSRMLS_CC);
|
||||
#endif
|
||||
if (tmp != EG(uninitialized_zval_ptr)) {
|
||||
return tmp;
|
||||
} else {
|
||||
return NULL;
|
||||
if (tmp == EG(uninitialized_zval_ptr)) {
|
||||
ZVAL_NULL(tmp);
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
|
||||
@@ -268,6 +268,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
$propertyObject = new Twig_TemplatePropertyObject();
|
||||
$propertyObject1 = new Twig_TemplatePropertyObjectAndIterator();
|
||||
$propertyObject2 = new Twig_TemplatePropertyObjectAndArrayAccess();
|
||||
$propertyObject3 = new Twig_TemplatePropertyObjectDefinedWithUndefinedValue();
|
||||
$methodObject = new Twig_TemplateMethodObject();
|
||||
$magicMethodObject = new Twig_TemplateMagicMethodObject();
|
||||
|
||||
@@ -317,6 +318,11 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
// additional properties tests
|
||||
$tests = array_merge($tests, array(
|
||||
array(true, null, $propertyObject3, 'foo', array(), $anyType),
|
||||
));
|
||||
|
||||
// additional method tests
|
||||
$tests = array_merge($tests, array(
|
||||
array(true, 'defined', $methodObject, 'defined', array(), $methodType),
|
||||
@@ -545,6 +551,16 @@ class Twig_TemplatePropertyObjectAndArrayAccess extends Twig_TemplatePropertyObj
|
||||
}
|
||||
}
|
||||
|
||||
class Twig_TemplatePropertyObjectDefinedWithUndefinedValue
|
||||
{
|
||||
public $foo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->foo = @$notExist;
|
||||
}
|
||||
}
|
||||
|
||||
class Twig_TemplateMethodObject
|
||||
{
|
||||
public function getDefined()
|
||||
|
||||
Reference in New Issue
Block a user