diff --git a/ChangeLog b/ChangeLog index bd8b3dc..b5f1d42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ memcached extension changelog +Version 1.0.1 +------------- + * Fix php_json.h inclusion. + Version 1.0.0 ------------- * First stable release. diff --git a/php_memcached.c b/php_memcached.c index e556aad..3584444 100644 --- a/php_memcached.c +++ b/php_memcached.c @@ -45,12 +45,15 @@ #include "php_memcached.h" -#ifdef HAVE_MEMCACHED_IGBINARY +#if HAVE_MEMCACHED_IGBINARY #include "ext/igbinary/igbinary.h" #endif -#ifdef HAVE_JSON_API +#if HAVE_JSON_API #include "ext/json/php_json.h" #endif +#if HAVE_JSON_API_5_3 +#include "ext/json/JSON_parser.h" +#endif /**************************************** Custom options @@ -1993,7 +1996,12 @@ static char *php_memc_zval_to_payload(zval *value, size_t *payload_len, uint32_t #if HAVE_JSON_API case SERIALIZER_JSON: { + +#if HAVE_JSON_API_5_2 php_json_encode(&buf, value TSRMLS_CC); +#elif HAVE_JSON_API_5_3 + php_json_encode(&buf, value, 0 TSRMLS_CC); //options +#endif buf.c[buf.len] = 0; MEMC_VAL_SET_TYPE(*flags, MEMC_VAL_IS_JSON); break; @@ -2157,9 +2165,13 @@ static int php_memc_zval_from_payload(zval *value, char *payload, size_t payload break; case MEMC_VAL_IS_JSON: -#if HAVE_JSON_API +#if HAVE_JSON_API_5_2 php_json_decode(value, payload, payload_len, 0 TSRMLS_CC); -#else +#elif HAVE_JSON_API_5_3 + php_json_decode(value, payload, payload_len, 0, JSON_PARSER_DEFAULT_DEPTH TSRMLS_CC); +#endif + +#if (!HAVE_JSON_API) php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not unserialize value, no json support"); return -1; #endif @@ -2791,7 +2803,7 @@ static const zend_module_dep memcached_deps[] = { #ifdef HAVE_MEMCACHED_SESSION ZEND_MOD_REQUIRED("session") #endif -#ifdef HAVA_MEMCACHED_IGBINARY +#ifdef HAVE_MEMCACHED_IGBINARY ZEND_MOD_REQUIRED("igbinary") #endif #ifdef HAVE_SPL @@ -2837,7 +2849,7 @@ static void php_memc_register_constants(INIT_FUNC_ARGS) /* * Indicate whether igbinary serializer is available */ -#ifdef HAVE_MEMCACHED_IGBINARY +#if HAVE_MEMCACHED_IGBINARY REGISTER_MEMC_CLASS_CONST_LONG(HAVE_IGBINARY, 1); #else REGISTER_MEMC_CLASS_CONST_LONG(HAVE_IGBINARY, 0); @@ -2846,7 +2858,7 @@ static void php_memc_register_constants(INIT_FUNC_ARGS) /* * Indicate whether json serializer is available */ -#ifdef HAVE_JSON_API +#if HAVE_JSON_API REGISTER_MEMC_CLASS_CONST_LONG(HAVE_JSON, 1); #else REGISTER_MEMC_CLASS_CONST_LONG(HAVE_JSON, 0); @@ -2998,6 +3010,12 @@ PHP_MINFO_FUNCTION(memcached) php_info_print_table_row(2, "igbinary support", "no"); #endif +#if HAVE_JSON_API + php_info_print_table_row(2, "json support", "yes"); +#else + php_info_print_table_row(2, "json support", "no"); +#endif + php_info_print_table_end(); } /* }}} */ diff --git a/php_memcached.h b/php_memcached.h index a8c4cf0..15c1ae7 100644 --- a/php_memcached.h +++ b/php_memcached.h @@ -67,9 +67,13 @@ PS_FUNCS(memcached); #endif /* json serializer */ -#if (PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 2) || (PHP_MAJOR_VERSION ==5 && PHP_MINOR_VERSION == 2 && PHP_RELEASE_VERSION > 9) -#define HAVE_JSON_API 1 +#if (PHP_MAJOR_VERSION ==5 && PHP_MINOR_VERSION == 2 && PHP_RELEASE_VERSION > 9) +#define HAVE_JSON_API_5_2 1 #endif +#if (PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 2) +#define HAVE_JSON_API_5_3 1 +#endif +#define HAVE_JSON_API (HAVE_JSON_API_5_2 || HAVE_JSON_API_5_3) #endif /* PHP_MEMCACHED_H */