In CDRIVER-2208, bson_as_json() (used by toJSON()) was reverted to its original output format. Canonical and relaxed extended JSON are now produced by bson_as_canonical_json() and bson_as_relaxed_json(), respectively. This commit removes toExtendedJSON() (added in 980f1fb01a) in favor of the new functions.
Implementations for the BSON functions have been moved to their own file, which is consistent with what we're doing for the APM subscriber functions.
This changes php_phongo_bson_typemap_to_state() to return a success boolean and also extracts class fetching into a separate php_phongo_bson_state_fetch_class() function to assist with supporting type wrappers in PHPC-640.
The modified ODS tests return atomic modifiers through bsonSerialize(), which conflicts with __pclass injection (the resulting newObj is neither an update nor a replacement document). Rather than delete these tests, we'll mark them as expecting failure until we allow such functionality in another interface down the line.
This simplifies calling bson_to_zval() quite a bit.
bson_to_zval() now takes empty zval*
bson_to_zval_ex() now takes php_phongo_bson_state (with empty zval*)
bson_to_zval() will always alloc and init state.zchild
Having seperate MongoDB\Driver\ and BSON\ namespace was overruled :(
However, when you install pecl/bson seperately, it can be in the BSON
namespace, as it is a standalone package just wrapping libbson.
Since pecl/bson will be maintained in the same source as phongo, and I'd
like to share the testcases etc, we introduce a compile flag to detect
if we are compiling phongo or just bson, and set the namespace
appropriately
Multiple things here -- we shouldn't be injecting __pclass every time
we serialize an object -- only when we are preparing it to be inserted.
Otherwise, for example when executing an update, it will be injected
into the update document too -- which b0rks the update statement.
We also need to bail out when we don't get an array from the serialize
callback -- and rather then pretend the return array from the callback
is the data we got passed in in the get-go, keep the original zval
intact so we don't accidentally convert it to array