@@ -963,36 +963,44 @@ bool phongo_execute_command(mongoc_client_t* client, php_phongo_command_type_t t
963963 goto cleanup ;
964964 }
965965
966- /* According to mongoc_cursor_new_from_command_reply (), the reply bson_t
967- * is ultimately destroyed on both success and failure. */
966+ /* According to mongoc_cursor_new_from_command_reply_with_opts (), the reply
967+ * bson_t is ultimately destroyed on both success and failure. */
968968 if (bson_iter_init_find (& iter , & reply , "cursor" ) && BSON_ITER_HOLDS_DOCUMENT (& iter )) {
969969 bson_t initial_reply = BSON_INITIALIZER ;
970+ bson_t cursor_opts = BSON_INITIALIZER ;
970971 bson_error_t error = { 0 };
971972
972973 bson_copy_to (& reply , & initial_reply );
973974
975+ bson_append_int32 (& cursor_opts , "serverId" , -1 , server_id );
976+
974977 if (command -> max_await_time_ms ) {
975- bson_append_bool (& initial_reply , "awaitData" , -1 , 1 );
976- bson_append_int64 (& initial_reply , "maxAwaitTimeMS" , -1 , command -> max_await_time_ms );
977- bson_append_bool (& initial_reply , "tailable" , -1 , 1 );
978+ bson_append_bool (& cursor_opts , "awaitData" , -1 , 1 );
979+ bson_append_int64 (& cursor_opts , "maxAwaitTimeMS" , -1 , command -> max_await_time_ms );
980+ bson_append_bool (& cursor_opts , "tailable" , -1 , 1 );
978981 }
979982
980983 if (command -> batch_size ) {
981- bson_append_int64 (& initial_reply , "batchSize" , -1 , command -> batch_size );
984+ bson_append_int64 (& cursor_opts , "batchSize" , -1 , command -> batch_size );
982985 }
983986
984- if (zsession && !mongoc_client_session_append (Z_SESSION_OBJ_P (zsession )-> client_session , & initial_reply , & error )) {
987+ if (zsession && !mongoc_client_session_append (Z_SESSION_OBJ_P (zsession )-> client_session , & cursor_opts , & error )) {
985988 phongo_throw_exception_from_bson_error_t (& error TSRMLS_CC );
986989 bson_destroy (& initial_reply );
990+ bson_destroy (& cursor_opts );
987991 result = false;
988992 goto cleanup ;
989993 }
990994
991- cmd_cursor = mongoc_cursor_new_from_command_reply (client , & initial_reply , server_id );
995+ cmd_cursor = mongoc_cursor_new_from_command_reply_with_opts (client , & initial_reply , & cursor_opts );
996+ bson_destroy (& cursor_opts );
992997 } else {
998+ bson_t cursor_opts = BSON_INITIALIZER ;
993999 bson_t * wrapped_reply = create_wrapped_command_envelope (db , & reply );
9941000
995- cmd_cursor = mongoc_cursor_new_from_command_reply (client , wrapped_reply , server_id );
1001+ bson_append_int32 (& cursor_opts , "serverId" , -1 , server_id );
1002+ cmd_cursor = mongoc_cursor_new_from_command_reply_with_opts (client , wrapped_reply , & cursor_opts );
1003+ bson_destroy (& cursor_opts );
9961004 }
9971005
9981006 phongo_cursor_init_for_command (return_value , client , cmd_cursor , db , zcommand , zreadPreference , zsession TSRMLS_CC );
0 commit comments