@@ -760,6 +760,7 @@ bool phongo_cursor_advance_and_check_for_error(mongoc_cursor_t* cursor TSRMLS_DC
760
760
bool phongo_execute_query (mongoc_client_t * client , const char * namespace , zval * zquery , zval * options , uint32_t server_id , zval * return_value , int return_value_used TSRMLS_DC ) /* {{{ */
761
761
{
762
762
const php_phongo_query_t * query ;
763
+ bson_t opts = BSON_INITIALIZER ;
763
764
mongoc_cursor_t * cursor ;
764
765
char * dbname ;
765
766
char * collname ;
@@ -777,30 +778,36 @@ bool phongo_execute_query(mongoc_client_t* client, const char* namespace, zval*
777
778
778
779
query = Z_QUERY_OBJ_P (zquery );
779
780
781
+ bson_copy_to (query -> opts , & opts );
782
+
780
783
if (query -> read_concern ) {
781
784
mongoc_collection_set_read_concern (collection , query -> read_concern );
782
785
}
783
786
784
787
if (!phongo_parse_read_preference (options , & zreadPreference TSRMLS_CC )) {
785
788
/* Exception should already have been thrown */
786
789
mongoc_collection_destroy (collection );
790
+ bson_destroy (& opts );
787
791
return false;
788
792
}
789
793
790
- if (!phongo_parse_session (options , client , query -> opts , & zsession TSRMLS_CC )) {
794
+ if (!phongo_parse_session (options , client , & opts , & zsession TSRMLS_CC )) {
791
795
/* Exception should already have been thrown */
792
796
mongoc_collection_destroy (collection );
797
+ bson_destroy (& opts );
793
798
return false;
794
799
}
795
800
796
- if (!BSON_APPEND_INT32 (query -> opts , "serverId" , server_id )) {
801
+ if (!BSON_APPEND_INT32 (& opts , "serverId" , server_id )) {
797
802
phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Error appending \"serverId\" option" );
798
803
mongoc_collection_destroy (collection );
804
+ bson_destroy (& opts );
799
805
return false;
800
806
}
801
807
802
- cursor = mongoc_collection_find_with_opts (collection , query -> filter , query -> opts , phongo_read_preference_from_zval (zreadPreference TSRMLS_CC ));
808
+ cursor = mongoc_collection_find_with_opts (collection , query -> filter , & opts , phongo_read_preference_from_zval (zreadPreference TSRMLS_CC ));
803
809
mongoc_collection_destroy (collection );
810
+ bson_destroy (& opts );
804
811
805
812
/* maxAwaitTimeMS must be set before the cursor is sent */
806
813
if (query -> max_await_time_ms ) {
0 commit comments