@@ -621,6 +621,7 @@ bool phongo_execute_write(mongoc_client_t *client, const char *namespace, php_ph
621
621
php_phongo_writeresult_t * writeresult ;
622
622
zval * zwriteConcern = NULL ;
623
623
const mongoc_write_concern_t * write_concern ;
624
+ bson_t * opts ;
624
625
625
626
if (bulk_write -> executed ) {
626
627
phongo_throw_exception (PHONGO_ERROR_WRITE_FAILED TSRMLS_CC , "BulkWrite objects may only be executed once and this instance has already been executed" );
@@ -632,10 +633,12 @@ bool phongo_execute_write(mongoc_client_t *client, const char *namespace, php_ph
632
633
return false;
633
634
}
634
635
636
+ opts = bson_new ();
637
+
635
638
/* FIXME: Legacy way of specifying the writeConcern option into this function */
636
639
if (options && Z_TYPE_P (options ) == IS_OBJECT && instanceof_function (Z_OBJCE_P (options ), php_phongo_writeconcern_ce TSRMLS_CC )) {
637
640
zwriteConcern = options ;
638
- } else if (!phongo_execute_parse_options (client , server_id , options , PHONGO_COMMAND_WRITE , NULL , NULL , & zwriteConcern TSRMLS_CC )) {
641
+ } else if (!phongo_execute_parse_options (client , server_id , options , PHONGO_COMMAND_WRITE , opts , NULL , & zwriteConcern TSRMLS_CC )) {
639
642
return false;
640
643
}
641
644
@@ -724,6 +727,7 @@ int phongo_execute_query(mongoc_client_t *client, const char *namespace, zval *z
724
727
char * collname ;
725
728
mongoc_collection_t * collection ;
726
729
zval * zreadPreference = NULL ;
730
+ bson_t * opts ;
727
731
728
732
if (!phongo_split_namespace (namespace , & dbname , & collname )) {
729
733
phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "%s: %s" , "Invalid namespace provided" , namespace );
@@ -738,11 +742,13 @@ int phongo_execute_query(mongoc_client_t *client, const char *namespace, zval *z
738
742
if (query -> read_concern ) {
739
743
mongoc_collection_set_read_concern (collection , query -> read_concern );
740
744
}
745
+
746
+ opts = bson_new ();
741
747
742
748
/* FIXME: Legacy way of specifying the readPreference option into this function */
743
749
if (options && Z_TYPE_P (options ) == IS_OBJECT && instanceof_function (Z_OBJCE_P (options ), php_phongo_readpreference_ce TSRMLS_CC )) {
744
750
zreadPreference = options ;
745
- } else if (!phongo_execute_parse_options (client , server_id , options , PHONGO_COMMAND_READ , NULL , & zreadPreference , NULL TSRMLS_CC )) {
751
+ } else if (!phongo_execute_parse_options (client , server_id , options , PHONGO_COMMAND_READ , opts , & zreadPreference , NULL TSRMLS_CC )) {
746
752
return false;
747
753
}
748
754
0 commit comments