From: Remi Collet Date: Thu, 5 Mar 2015 14:06:11 +0000 (+0100) Subject: Fix PHP 5.3 build X-Git-Tag: v1.0.0RC1~2 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-json_post;a=commitdiff_plain;h=f20dbc497058da8f206b53718b109728ad280048 Fix PHP 5.3 build But can't test, all tests are skipped (reason: CGI not available..) --- diff --git a/php_json_post.c b/php_json_post.c index 6bc8c33..ae7e3a6 100644 --- a/php_json_post.c +++ b/php_json_post.c @@ -30,7 +30,11 @@ PHP_INI_END() static void php_json_post_init_globals(zend_json_post_globals *json_post_globals) { +#if PHP_VERSION_ID >= 50400 json_post_globals->flags = PHP_JSON_OBJECT_AS_ARRAY; +#else + json_post_globals->flags = 1; +#endif } PHP_MINFO_FUNCTION(json_post) @@ -63,10 +67,18 @@ static SAPI_POST_HANDLER_FUNC(php_json_post_handler) zval zjson; INIT_ZVAL(zjson); +#if PHP_VERSION_ID >= 50400 php_json_decode_ex(&zjson, json_str, json_len, JSON_POST_G(flags), PG(max_input_nesting_level) TSRMLS_CC); - if (Z_TYPE(zjson) != IS_NULL) { + if (Z_TYPE(zjson) != IS_NULL) { zval_dtor(zarg); ZVAL_COPY_VALUE(zarg, (&zjson)); +#else + php_json_decode(&zjson, json_str, json_len, (zend_bool)(JSON_POST_G(flags)&1), PG(max_input_nesting_level) TSRMLS_CC); + if (Z_TYPE(zjson) != IS_NULL) { + zval_dtor(zarg); + zarg->value = zjson.value; + Z_TYPE_P(zarg) = Z_TYPE(zjson); +#endif } } #if PHP_VERSION_ID >= 50600