This removes the invalidate_current handler. Due to SPL's implementation, our handler was being invoked between rewinding and checking if the current position was valid. Given that our validity check depends on inspecting a pointer to the current element (like MySQLi's result iterator), we cannot use invalidate_current.
The current element must still be freed during iteration, so we will instead call a php_phongo_cursor_free_current() function as needed. Additionally, we should track a reference to the Cursor object zval on the iterator itself, which will ensure it is not garbage-collected during iteration (demonstrated in the segfault backtrace in PHPC-215).
Lastly, this commit renames the Cursor object and iterator structs and related functions to be more consistent with implementions in PHP core.
We copy the write concern struct rather than store an is_acknowledged boolean, which allows us to include the write concern in the debug output. Down the line, we may decide to implement a getWriteConcern() method to help users in handling/logging write concern errors.
For execute[Insert|Update|Delete]() we unroll the BulkWrite exception
and throw the inner errors.
Note: WriteConcern failure now throws WriteConcernException!
This is a basic ODM.
When a class implements the BSON\Persistable interface gets bson
encoded we will embed a __ binary(type=0x80) value into the document.
Upon bson decoding a document, if we find that binary type convert that
document/array into the php class
The point of it was to bactract to which batch index it belonged to.
We now return correctly indexed array for this, a long with the actual id
for the upsert
This exception extends SPL RuntimeException - and implements
MongoDB\Exception
This makes it easy to catch "all MongoDB exceptions" and/or
RuntimeExceptions
When initializing a WriteResult, we should initialize the corresponding WriteError and WriteConcernError classes, too. This moves all of the initialization code into php_phongoc, as was done with the error classes.
Additionally, phongo_execute_write() has been changed to not construct a bson_t reply unnecessarily (i.e. return value will not be used).