summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2014-10-28 22:14:35 +0100
committerBob Weinand <bobwei9@hotmail.com>2014-10-28 22:14:35 +0100
commitd25cc7f09085ea8f162a984b8345c6ecaebf0a65 (patch)
tree2ca6ac0174e34b3377716f0f87fc024c21d7193e
parent69b999eb7ed802f488f674f8d4294e09e6d46610 (diff)
downloadphp-git-d25cc7f09085ea8f162a984b8345c6ecaebf0a65.tar.gz
Use serialize instead of json for transfer
-rw-r--r--config.m45
-rw-r--r--phpdbg_wait.c15
-rw-r--r--phpdbg_webdata_transfer.c20
3 files changed, 21 insertions, 19 deletions
diff --git a/config.m4 b/config.m4
index b8aa8526c5..9603be105c 100644
--- a/config.m4
+++ b/config.m4
@@ -25,11 +25,6 @@ if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then
if ! test -d $abs_srcdir/ext/phpdbg_webhelper; then
ln -s ../sapi/phpdbg $abs_srcdir/ext/phpdbg_webhelper
fi
- if test "$PHP_JSON" != "no"; then
- PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared)
- else
- AC_MSG_ERROR(Webhelper extension of phpdbg needs json enabled)
- fi
fi
PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE"
diff --git a/phpdbg_wait.c b/phpdbg_wait.c
index ea506a2d93..bdce77180b 100644
--- a/phpdbg_wait.c
+++ b/phpdbg_wait.c
@@ -18,7 +18,7 @@
#include "phpdbg_wait.h"
#include "phpdbg_prompt.h"
-#include "ext/json/JSON_parser.h"
+#include "ext/standard/php_var.h"
#include "ext/standard/basic_functions.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
@@ -127,16 +127,18 @@ static int phpdbg_array_intersect(phpdbg_intersect_ptr *info, zval ***ptr) {
}
void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) {
-#ifdef HAVE_JSON
zval *free_zv = NULL;
- zval zv, **zvpp;
+ zval zv, *zvp = &zv, **zvpp;
HashTable *ht;
- php_json_decode(&zv, msg, len, 1, 1000 /* enough */ TSRMLS_CC);
+ php_unserialize_data_t var_hash;
- if (JSON_G(error_code) != PHP_JSON_ERROR_NONE) {
- phpdbg_error("wait", "type=\"invaliddata\" import=\"fail\"", "Malformed JSON was sent to this socket, arborting");
+ PHP_VAR_UNSERIALIZE_INIT(var_hash);
+ if (!php_var_unserialize(&zvp, (const unsigned char **) &msg, (unsigned char *) msg + len, &var_hash TSRMLS_CC)) {
+ PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
+ phpdbg_error("wait", "type=\"invaliddata\" import=\"fail\"", "Malformed serialized was sent to this socket, arborting");
return;
}
+ PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
ht = Z_ARRVAL(zv);
@@ -358,7 +360,6 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) {
/* Reapply raw input */
/* ??? */
-#endif
}
PHPDBG_COMMAND(wait) /* {{{ */
diff --git a/phpdbg_webdata_transfer.c b/phpdbg_webdata_transfer.c
index e7438ea01a..1cbc4107b5 100644
--- a/phpdbg_webdata_transfer.c
+++ b/phpdbg_webdata_transfer.c
@@ -17,11 +17,9 @@
*/
#include "phpdbg_webdata_transfer.h"
-#include "ext/json/php_json.h"
+#include "ext/standard/php_var.h"
PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) {
-#ifdef HAVE_JSON
- smart_str buf = {0};
zval array;
HashTable *ht;
/* I really need to change that to an array of zvals... */
@@ -177,9 +175,17 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) {
}
/* encode data */
- php_json_encode(&buf, &array, 0 TSRMLS_CC);
- *msg = buf.c;
- *len = buf.len;
+ {
+ php_serialize_data_t var_hash;
+ smart_str buf = {0};
+ zval *arrayptr = &array;
+
+ PHP_VAR_SERIALIZE_INIT(var_hash);
+ php_var_serialize(&buf, &arrayptr, &var_hash TSRMLS_CC);
+ PHP_VAR_SERIALIZE_DESTROY(var_hash);
+ *msg = buf.c;
+ *len = buf.len;
+ }
+
zval_dtor(&array);
-#endif
}