Skip to content

Commit 560dc81

Browse files
committed
Merged pull request #390
2 parents afe8fc0 + 2e89b1c commit 560dc81

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/BSON/Javascript.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ *
330330
}
331331

332332
zval_ptr_dtor(&state.zchild);
333+
} else {
334+
zval scope;
335+
336+
ZVAL_NULL(&scope);
337+
zend_hash_str_update(props, "scope", sizeof("scope")-1, &scope);
333338
}
334339
}
335340
#else
@@ -355,6 +360,12 @@ HashTable *php_phongo_javascript_get_properties(zval *object TSRMLS_DC) /* {{{ *
355360
}
356361

357362
zval_ptr_dtor(&state.zchild);
363+
} else {
364+
zval *scope;
365+
366+
MAKE_STD_ZVAL(scope);
367+
ZVAL_NULL(scope);
368+
zend_hash_update(props, "scope", sizeof("scope"), &scope, sizeof(scope), NULL);
358369
}
359370
}
360371
#endif

tests/bson/bson-javascript-serialization-001.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ foreach ($tests as $test) {
2626
object(MongoDB\BSON\Javascript)#%d (%d) {
2727
["code"]=>
2828
string(33) "function foo(bar) { return bar; }"
29+
["scope"]=>
30+
NULL
2931
}
30-
string(87) "O:23:"MongoDB\BSON\Javascript":1:{s:4:"code";s:33:"function foo(bar) { return bar; }";}"
32+
string(101) "O:23:"MongoDB\BSON\Javascript":2:{s:4:"code";s:33:"function foo(bar) { return bar; }";s:5:"scope";N;}"
3133
object(MongoDB\BSON\Javascript)#%d (%d) {
3234
["code"]=>
3335
string(33) "function foo(bar) { return bar; }"
36+
["scope"]=>
37+
NULL
3438
}
3539

3640
object(MongoDB\BSON\Javascript)#%d (%d) {

tests/bson/bson-javascript-set_state-001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ echo "\n\n";
3232
--EXPECTF--
3333
MongoDB\BSON\Javascript::__set_state(array(
3434
'code' => 'function foo(bar) { return bar; }',
35+
'scope' => NULL,
3536
))
3637

3738
MongoDB\BSON\Javascript::__set_state(array(
@@ -62,6 +63,7 @@ MongoDB\BSON\Javascript::__set_state(array(
6263

6364
MongoDB\BSON\Javascript::__set_state(array(
6465
'code' => 'function foo(bar) { return bar; }',
66+
'scope' => NULL,
6567
))
6668

6769
===DONE===

0 commit comments

Comments
 (0)