X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-json_post;a=blobdiff_plain;f=php_json_post.c;h=77ceb8d3854fe20c208d2a3c76885223210df949;hp=94e0e36eb9cc996811df4560dcb39d5232861c95;hb=c1b0270e93fc2706027296233553933d03d3fd1e;hpb=129e8b459061f9f4c76e3ee8a6baaef68c0bba41 diff --git a/php_json_post.c b/php_json_post.c index 94e0e36..77ceb8d 100644 --- a/php_json_post.c +++ b/php_json_post.c @@ -41,16 +41,12 @@ static void php_json_post_init_globals(zend_json_post_globals *json_post_globals #endif } -#if PHP_VERSION_ID < 70000 -ZEND_EXTERN_MODULE_GLOBALS(json); -#endif - #ifndef TSRMLS_CC +# define TSRMLS_D # define TSRMLS_C # define TSRMLS_CC #endif - PHP_MINFO_FUNCTION(json_post) { php_info_print_table_start(); @@ -60,6 +56,15 @@ PHP_MINFO_FUNCTION(json_post) DISPLAY_INI_ENTRIES(); } +#if PHP_VERSION_ID < 70000 +# undef JSON_G +# ifdef ZTS +# define JSON_G(v) TSRMG(JSON_POST_G(json_module)->globals_id_ptr, zend_json_globals *, v) +# else +# define JSON_G(v) ((zend_json_globals *) JSON_POST_G(json_module)->globals_ptr)->v +# endif +#endif + static SAPI_POST_HANDLER_FUNC(php_json_post_handler) { int module_number = 0; @@ -162,8 +167,10 @@ static SAPI_POST_HANDLER_FUNC(php_json_post_handler) sapi_send_headers(TSRMLS_C); zend_bailout(); } +#if PHP_VERSION_ID >= 70000 && PHP_VERSION_ID < 80000 /* ext/json in PHP-7 fails to reset error_code in RINIT */ JSON_G(error_code) = 0; +#endif } } @@ -178,6 +185,11 @@ PHP_MINIT_FUNCTION(json_post) sapi_register_post_entries(json_post_entries TSRMLS_CC); ZEND_INIT_MODULE_GLOBALS(json_post, php_json_post_init_globals, NULL); + +#if PHP_VERSION_ID < 70000 + zend_hash_find(&module_registry, ZEND_STRS("json"), (void **) &JSON_POST_G(json_module)); +#endif + REGISTER_INI_ENTRIES(); return SUCCESS; }