From: Arnaud Le Blanc Date: Thu, 23 Aug 2012 11:58:44 +0000 (+0200) Subject: [ext] fixed php 5.2 ZTS builds X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=46ce33972f201532d42d8c56152a8d811ebb9768;p=web%2Fkonrad%2Ftwig.git [ext] fixed php 5.2 ZTS builds zend_hash_apply_with_arguments and its callback argument do not have a TSRMLS in php 5.2. --- diff --git a/ext/twig/twig.c b/ext/twig/twig.c index 498392d..71084a4 100644 --- a/ext/twig/twig.c +++ b/ext/twig/twig.c @@ -29,6 +29,16 @@ #define Z_ADDREF_P(pz) (pz)->refcount++ #endif +#if PHP_VERSION_ID >= 50300 + #define APPLY_TSRMLS_DC TSRMLS_DC + #define APPLY_TSRMLS_CC TSRMLS_CC + #define APPLY_TSRMLS_FETCH() +#else + #define APPLY_TSRMLS_DC + #define APPLY_TSRMLS_CC + #define APPLY_TSRMLS_FETCH() TSRMLS_FETCH() +#endif + ZEND_BEGIN_ARG_INFO_EX(twig_template_get_attribute_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 6) ZEND_ARG_INFO(0, template) ZEND_ARG_INFO(0, object) @@ -501,8 +511,9 @@ void TWIG_NEW(zval *object, char *class, zval *arg0, zval *arg1 TSRMLS_DC) TWIG_CALL_ZZ(object, "__construct", arg0, arg1 TSRMLS_CC); } -static int twig_add_array_key_to_string(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int twig_add_array_key_to_string(void *pDest APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { + APPLY_TSRMLS_FETCH(); smart_str *buf; char *joiner; @@ -534,7 +545,7 @@ char *TWIG_IMPLODE_ARRAY_KEYS(char *joiner, zval *array TSRMLS_DC) smart_str collector = { 0, 0, 0 }; smart_str_appendl(&collector, "", 0); - zend_hash_apply_with_arguments(HASH_OF(array) TSRMLS_CC, twig_add_array_key_to_string, 2, &collector, joiner); + zend_hash_apply_with_arguments(HASH_OF(array) APPLY_TSRMLS_CC, twig_add_array_key_to_string, 2, &collector, joiner); smart_str_0(&collector); return collector.c; @@ -570,8 +581,9 @@ char *TWIG_GET_CLASS_NAME(zval *object TSRMLS_DC) return class_name; } -static int twig_add_method_to_class(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int twig_add_method_to_class(void *pDest APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { + APPLY_TSRMLS_FETCH(); zval *retval; char *item; size_t item_len; @@ -592,8 +604,9 @@ static int twig_add_method_to_class(void *pDest TSRMLS_DC, int num_args, va_list return 0; } -static int twig_add_property_to_class(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int twig_add_property_to_class(void *pDest APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { + APPLY_TSRMLS_FETCH(); zend_class_entry *ce; zval *retval; char *class_name, *prop_name; @@ -614,8 +627,9 @@ static int twig_add_property_to_class(void *pDest TSRMLS_DC, int num_args, va_li } /* {{{ _adddynproperty */ -static int twig_add_dyn_property_to_class(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int twig_add_dyn_property_to_class(void *pDest APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { + APPLY_TSRMLS_FETCH(); zend_class_entry *ce = *va_arg(args, zend_class_entry**); zval *retval = va_arg(args, zval*), member; char *class_name, *prop_name; @@ -646,12 +660,12 @@ static void twig_add_class_to_cache(zval *cache, zval *object, char *class_name array_init(class_methods); array_init(class_properties); // add all methods to self::cache[$class]['methods'] - zend_hash_apply_with_arguments(&class_ce->function_table TSRMLS_CC, twig_add_method_to_class, 1, class_methods); - zend_hash_apply_with_arguments(&class_ce->properties_info TSRMLS_CC, twig_add_property_to_class, 2, &class_ce, class_properties); + zend_hash_apply_with_arguments(&class_ce->function_table APPLY_TSRMLS_CC, twig_add_method_to_class, 1, class_methods); + zend_hash_apply_with_arguments(&class_ce->properties_info APPLY_TSRMLS_CC, twig_add_property_to_class, 2, &class_ce, class_properties); if (object && Z_OBJ_HT_P(object)->get_properties) { HashTable *properties = Z_OBJ_HT_P(object)->get_properties(object TSRMLS_CC); - zend_hash_apply_with_arguments(properties TSRMLS_CC, twig_add_dyn_property_to_class, 2, &class_ce, class_properties); + zend_hash_apply_with_arguments(properties APPLY_TSRMLS_CC, twig_add_dyn_property_to_class, 2, &class_ce, class_properties); } add_assoc_zval(class_info, "methods", class_methods); add_assoc_zval(class_info, "properties", class_properties);