From 1b55c97eba94cdd94cadff35387f9b7f051d1990 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Mon, 4 Jul 2011 16:46:33 +0100 Subject: [PATCH] Only add the object to the cache if there is actually an object. --- twig.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/twig.c b/twig.c index cf79f54..f3bbbec 100644 --- a/twig.c +++ b/twig.c @@ -554,13 +554,16 @@ PHP_FUNCTION(twig_template_get_attributes) } } */ - char *class_name = TWIG_GET_CLASS_NAME(object); + char *class_name; zval *tmp_self_cache; - - tmp_self_cache = TWIG_GET_STATIC_PROPERTY(template, "cache"); - if (!TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name, strlen(class_name))) { - twig_add_class_to_cache(tmp_self_cache, object, class_name); + if (Z_TYPE_P(object) == IS_OBJECT) { + class_name = TWIG_GET_CLASS_NAME(object); + tmp_self_cache = TWIG_GET_STATIC_PROPERTY(template, "cache"); + + if (!TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name, strlen(class_name))) { + twig_add_class_to_cache(tmp_self_cache, object, class_name); + } } /* -- 1.7.2.5