-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.2.9
-
Component/s: None
-
None
As reported in mongodb/mongo-php-driver#603:
<?php var_dump(\MongoDB\BSON\toPHP(\MongoDB\BSON\fromJson('{"myArray": [{"$oid": "2017-06-13T11:21:26.906Z"}]}'))); echo "\n"; var_dump(\MongoDB\BSON\toPHP(\MongoDB\BSON\fromJson('[1,2,3,{"$date": "2017-06-13T11:21:26.906Z"}]'))); echo "\n"; var_dump(\MongoDB\BSON\toPHP(\MongoDB\BSON\fromJson('[{"$oid": "55f2b3f1f657b3fa97c9c0a2"},{"$date": "2017-06-13T11:21:26.906Z"}]')));
This produces the following output:
object(stdClass)#2 (1) { ["myArray"]=> array(1) { [0]=> object(MongoDB\BSON\ObjectID)#1 (1) { ["oid"]=> string(24) "201700601301102102609060" } } } object(stdClass)#1 (4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [4]=> object(MongoDB\BSON\UTCDateTime)#2 (1) { ["milliseconds"]=> string(13) "1497352886906" } } object(stdClass)#3 (2) { [1]=> object(MongoDB\BSON\ObjectID)#1 (1) { ["oid"]=> string(24) "55f2b3f1f657b3fa97c9c0a2" } [3]=> object(MongoDB\BSON\UTCDateTime)#2 (1) { ["milliseconds"]=> string(13) "1497352886906" } }
In the second and third examples, conversion introduces gaps in the array indexes. While unrelated to PHPC, the HHVM driver also demonstrates a gap in the first example (see GitHub issue).
- depends on
-
CDRIVER-994 "[{$numberLong: '1'}]" is BSON-encoded with array key name "1"
- Closed
-
PHPC-892 Upgrade libbson and libmongoc to 1.6.0
- Closed
- links to