This ensures that libmongoc's automatic destructor is disabled and will avoid segfaults during abrupt FPM shutdowns for static builds.
Those using the driver with system libmongoc will need to wait for CDRIVER-1160 to be released in order to resolve this issue.
Fixes#209, fixes#258
This adds additional error tests for toJSON(), which demonstrate the problem when both exceptions might have been thrown.
Additionally, this ensures that the bson_reader_t is freed before returning. Previously, the code relied on the free after the second exception was thrown.
Freeing the current zval in the corrupt BSON visitor causes a segfault if done for the root document, since phongo_bson_to_zval_ex() expects the calling code to initialize and free that zval on success or error.
That said, we should free when encountering an error via the document or array visitors (i.e. nested context), which would have just been initialized.
This removes a SKIPIF from the 32-bit test but leaves the 64-bit test in place, since it tests construction from a 64-bit integer type instead of a string.
This adds range checking to Timestamp's constructor and changes Timestamp::__toString() to print the components as unsigned 32-bit integers. Internal structs and functions were changed to use uint32_t for readability.
32-bit platforms will be limited to the range of signed 32-bit integers, since PHP has no unsigned integer type. This will be documented in PHPC-599.
This ensures that we properly check for 64-bit support in PHP 7.
Additionally, we relocate variable declarations and consolidate the conditionals so that "milliseconds" is only declared when used.
Define phongo_long and SIZEOF_PHONGO_LONG in compatibility header. On PHP 7, this will ensure we use zend_long and SIZEOF_ZEND_LONG instead of relying on long and SIZEOF_LONG.
Additionally, this adds an else condition to report a build error if the architecture is neither 32-bit nor 64-bit.
The previous macro uses ZEND_STRL(), which calculates the string length via sizeof() and makes it suitable only for string literals. Since this code is utilized by php_phongo_bson_visit_int64(), we must rely on strlen() to compute the field name length.