From: Charles Date: Fri, 21 Sep 2012 10:29:41 +0000 (+0700) Subject: Twig extension: fix case when accessing property of an array casted into object X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=9126dc649c2f501ddc4a0c9d8095158d82ecaf16;p=web%2Fkonrad%2Ftwig.git Twig extension: fix case when accessing property of an array casted into object --- diff --git a/ext/twig/twig.c b/ext/twig/twig.c index 4476bb7..c94fa0f 100644 --- a/ext/twig/twig.c +++ b/ext/twig/twig.c @@ -317,14 +317,14 @@ int TWIG_HAS_PROPERTY(zval *object, zval *propname TSRMLS_DC) return 0; } -int TWIG_HAS_DYNAMIC_PROPERTY(zval *object, zval *propname TSRMLS_DC) +int TWIG_HAS_DYNAMIC_PROPERTY(zval *object, char *prop, int prop_len TSRMLS_DC) { - if (Z_OBJ_HT_P(object)->get_properties && Z_OBJ_HT_P(object)->get_properties != zend_std_get_properties) { + if (Z_OBJ_HT_P(object)->get_properties) { return zend_hash_quick_exists( - Z_OBJ_HT_P(object)->get_properties(object TSRMLS_CC), // the properties hash - Z_STRVAL(*propname), // property name - Z_STRLEN(*propname)+1, // property length - zend_get_hash_value(Z_STRVAL(*propname), Z_STRLEN(*propname)+1) // hash value + Z_OBJ_HT_P(object)->get_properties(object TSRMLS_CC), // the properties hash + prop, // property name + prop_len + 1, // property length + zend_get_hash_value(prop, prop_len + 1) // hash value ); } return 0; @@ -842,7 +842,7 @@ PHP_FUNCTION(twig_template_get_attributes) efree(class_name); - if (tmp_item || TWIG_HAS_PROPERTY(object, &zitem TSRMLS_CC) || TWIG_HAS_DYNAMIC_PROPERTY(object, &zitem TSRMLS_CC)) { + if (tmp_item || TWIG_HAS_PROPERTY(object, &zitem TSRMLS_CC) || TWIG_HAS_DYNAMIC_PROPERTY(object, item, item_len TSRMLS_CC)) { if (isDefinedTest) { RETURN_TRUE; }