When doing async connections we can't properly determine if we should connect over IPv6 or IPv4. PHP will unfortunately default to connecting over IPv6 (when compiled in support, with minor runtime check), while mongod does not support IPv6 by default.
When then creating the IPv6 connection asynchronously, PHP hits EINPROGRESS and will happily return the socket as valid.
There currently is no way to configure these functions to prefer IPv4. The best we can do for now is to not connect asynchronously as then we'll properly discover that the IPv6 socket failed, and then continue through the list of addrinfo and next pickup the IPv4 address which works.
Fixes#133
This makes WriteException a common base class of WriteConcernException and WriteErrorException. BulkWriteException, which may contain multiple write and/or write concern errors, will continue to inherit WriteException.
This class was not being used, since executeBulkWrite() uses BulkWriteException and the single write methods use WriteException and WriteConcernException exclusively.
When closing a stream we can't free the base_stream, only our stream.
Which also means, when destroying a stream we may not always have a wrapping stream
The read preference and write concern are complex structures, so we can't simply set their options on the URI as we do for other things (e.g. auth credentials).
If the URI cannot be parsed, we should throw an InvalidArgumentException. Failing to initialize the client from a valid URI can remain a RuntimeException.
The modifiers and selector zvals are both arrays or objects by this point and zval_to_bson() will handle either. Each will be serialized as a BSON document since zval_to_bson() merely appends fields to the structure we initialize with bson_new().
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