PHPC-769: Javascript serialization, export, and dump should always include scope field

This commit is contained in:
Derick Rethans
2016-09-06 14:14:36 +01:00
parent afe8fc0138
commit 2e89b1cfb2
3 changed files with 18 additions and 1 deletions
+11
View File
@@ -330,6 +330,11 @@ HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ *
}
zval_ptr_dtor(&state.zchild);
} else {
zval scope;
ZVAL_NULL(&scope);
zend_hash_str_update(props, "scope", sizeof("scope")-1, &scope);
}
}
#else
@@ -355,6 +360,12 @@ HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ *
}
zval_ptr_dtor(&state.zchild);
} else {
zval *scope;
MAKE_STD_ZVAL(scope);
ZVAL_NULL(scope);
zend_hash_update(props, "scope", sizeof("scope"), &scope, sizeof(scope), NULL);
}
}
#endif
@@ -26,11 +26,15 @@ foreach ($tests as $test) {
object(MongoDB\BSON\Javascript)#%d (%d) {
["code"]=>
string(33) "function foo(bar) { return bar; }"
["scope"]=>
NULL
}
string(87) "O:23:"MongoDB\BSON\Javascript":1:{s:4:"code";s:33:"function foo(bar) { return bar; }";}"
string(101) "O:23:"MongoDB\BSON\Javascript":2:{s:4:"code";s:33:"function foo(bar) { return bar; }";s:5:"scope";N;}"
object(MongoDB\BSON\Javascript)#%d (%d) {
["code"]=>
string(33) "function foo(bar) { return bar; }"
["scope"]=>
NULL
}
object(MongoDB\BSON\Javascript)#%d (%d) {
@@ -32,6 +32,7 @@ echo "\n\n";
--EXPECTF--
MongoDB\BSON\Javascript::__set_state(array(
'code' => 'function foo(bar) { return bar; }',
'scope' => NULL,
))
MongoDB\BSON\Javascript::__set_state(array(
@@ -62,6 +63,7 @@ MongoDB\BSON\Javascript::__set_state(array(
MongoDB\BSON\Javascript::__set_state(array(
'code' => 'function foo(bar) { return bar; }',
'scope' => NULL,
))
===DONE===