From 53e1652d805c84528ee57a47551ad496be6492ee Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Mon, 18 Jul 2011 18:46:12 +0100 Subject: [PATCH] Implement HAS_PROPERTY to distinguish between not-set and NULL. --- twig.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/twig.c b/twig.c index eefc4cb..6fc3973 100644 --- a/twig.c +++ b/twig.c @@ -356,6 +356,18 @@ zval *TWIG_PROPERTY(zval *object, zval *propname) return tmp; } +zval *TWIG_HAS_PROPERTY(zval *object, zval *propname) +{ + char *prot_name; + int prot_name_length; + zval *tmp = 1; + + if (Z_OBJ_HT_P(object)->has_property) { + return Z_OBJ_HT_P(object)->has_property(object, propname, 0 TSRMLS_CC); + } + return 0; +} + zval *TWIG_PROPERTY_CHAR(zval *object, char *propname) { zval *tmp_name_zval, *tmp; @@ -818,10 +830,9 @@ PHP_FUNCTION(twig_template_get_attributes) tmp_properties = TWIG_GET_ARRAY_ELEMENT(tmp_class, "properties", strlen("properties")); tmp_item = TWIG_GET_ARRAY_ELEMENT_ZVAL(tmp_properties, item); - tmp_object_item = TWIG_PROPERTY(object, item); efree(class_name); - if (tmp_item || tmp_object_item || TWIG_ARRAY_KEY_EXISTS(object, item) // FIXME: Array key? is that array access here? + if (tmp_item || TWIG_HAS_PROPERTY(object, item) || TWIG_ARRAY_KEY_EXISTS(object, item) // FIXME: Array key? is that array access here? ) { if (isDefinedTest) { RETURN_TRUE; -- 1.7.2.5