Skip to content

Commit d07d180

Browse files
committed
Merge branch 'v1.5'
2 parents f6e8d65 + f8d3781 commit d07d180

File tree

5 files changed

+10
-27
lines changed

5 files changed

+10
-27
lines changed

php_phongo.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,7 @@ bool phongo_cursor_advance_and_check_for_error(mongoc_cursor_t* cursor TSRMLS_DC
807807
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) /* {{{ */
808808
{
809809
const php_phongo_query_t* query;
810+
bson_t opts = BSON_INITIALIZER;
810811
mongoc_cursor_t* cursor;
811812
char* dbname;
812813
char* collname;
@@ -824,30 +825,36 @@ bool phongo_execute_query(mongoc_client_t* client, const char* namespace, zval*
824825

825826
query = Z_QUERY_OBJ_P(zquery);
826827

828+
bson_copy_to(query->opts, &opts);
829+
827830
if (query->read_concern) {
828831
mongoc_collection_set_read_concern(collection, query->read_concern);
829832
}
830833

831834
if (!phongo_parse_read_preference(options, &zreadPreference TSRMLS_CC)) {
832835
/* Exception should already have been thrown */
833836
mongoc_collection_destroy(collection);
837+
bson_destroy(&opts);
834838
return false;
835839
}
836840

837-
if (!phongo_parse_session(options, client, query->opts, &zsession TSRMLS_CC)) {
841+
if (!phongo_parse_session(options, client, &opts, &zsession TSRMLS_CC)) {
838842
/* Exception should already have been thrown */
839843
mongoc_collection_destroy(collection);
844+
bson_destroy(&opts);
840845
return false;
841846
}
842847

843-
if (!BSON_APPEND_INT32(query->opts, "serverId", server_id)) {
848+
if (!BSON_APPEND_INT32(&opts, "serverId", server_id)) {
844849
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error appending \"serverId\" option");
845850
mongoc_collection_destroy(collection);
851+
bson_destroy(&opts);
846852
return false;
847853
}
848854

849-
cursor = mongoc_collection_find_with_opts(collection, query->filter, query->opts, phongo_read_preference_from_zval(zreadPreference TSRMLS_CC));
855+
cursor = mongoc_collection_find_with_opts(collection, query->filter, &opts, phongo_read_preference_from_zval(zreadPreference TSRMLS_CC));
850856
mongoc_collection_destroy(collection);
857+
bson_destroy(&opts);
851858

852859
/* maxAwaitTimeMS must be set before the cursor is sent */
853860
if (query->max_await_time_ms) {

tests/manager/manager-executeQuery-001.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
5656
["y"]=>
5757
int(1)
5858
}
59-
["serverId"]=>
60-
int(%d)
6159
}
6260
["readConcern"]=>
6361
NULL

tests/manager/manager-executeQuery-002.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
5555
["y"]=>
5656
int(1)
5757
}
58-
["serverId"]=>
59-
int(%d)
6058
}
6159
["readConcern"]=>
6260
NULL

tests/readPreference/bug0146-001.phpt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
4646
}
4747
["options"]=>
4848
object(stdClass)#%d (%d) {
49-
["serverId"]=>
50-
int(%d)
5149
}
5250
["readConcern"]=>
5351
NULL
@@ -86,8 +84,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
8684
}
8785
["options"]=>
8886
object(stdClass)#%d (%d) {
89-
["serverId"]=>
90-
int(%d)
9187
}
9288
["readConcern"]=>
9389
NULL
@@ -126,8 +122,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
126122
}
127123
["options"]=>
128124
object(stdClass)#%d (%d) {
129-
["serverId"]=>
130-
int(%d)
131125
}
132126
["readConcern"]=>
133127
NULL
@@ -166,8 +160,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
166160
}
167161
["options"]=>
168162
object(stdClass)#%d (%d) {
169-
["serverId"]=>
170-
int(%d)
171163
}
172164
["readConcern"]=>
173165
NULL
@@ -206,8 +198,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
206198
}
207199
["options"]=>
208200
object(stdClass)#%d (%d) {
209-
["serverId"]=>
210-
int(%d)
211201
}
212202
["readConcern"]=>
213203
NULL

tests/readPreference/bug0146-002.phpt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
4848
}
4949
["options"]=>
5050
object(stdClass)#%d (%d) {
51-
["serverId"]=>
52-
int(%d)
5351
}
5452
["readConcern"]=>
5553
NULL
@@ -88,8 +86,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
8886
}
8987
["options"]=>
9088
object(stdClass)#%d (%d) {
91-
["serverId"]=>
92-
int(%d)
9389
}
9490
["readConcern"]=>
9591
NULL
@@ -128,8 +124,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
128124
}
129125
["options"]=>
130126
object(stdClass)#%d (%d) {
131-
["serverId"]=>
132-
int(%d)
133127
}
134128
["readConcern"]=>
135129
NULL
@@ -168,8 +162,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
168162
}
169163
["options"]=>
170164
object(stdClass)#%d (%d) {
171-
["serverId"]=>
172-
int(%d)
173165
}
174166
["readConcern"]=>
175167
NULL
@@ -208,8 +200,6 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
208200
}
209201
["options"]=>
210202
object(stdClass)#%d (%d) {
211-
["serverId"]=>
212-
int(%d)
213203
}
214204
["readConcern"]=>
215205
NULL

0 commit comments

Comments
 (0)