From f20dbc497058da8f206b53718b109728ad280048 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 5 Mar 2015 15:06:11 +0100 Subject: [PATCH] Fix PHP 5.3 build But can't test, all tests are skipped (reason: CGI not available..) --- php_json_post.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 -- 2.30.2