Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions php_phongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,9 @@ int phongo_execute_query(mongoc_client_t *client, const char *namespace, const p
return false;
}

cursor->hint = server_id;
if (server_id > 0) {
cursor->hint = server_id;
}
if (!mongoc_cursor_next(cursor, &doc)) {
bson_error_t error;

Expand Down Expand Up @@ -733,7 +735,9 @@ int phongo_execute_command(mongoc_client_t *client, const char *db, const bson_t


cursor = mongoc_client_command(client, db, MONGOC_QUERY_NONE, 0, 1, 0, command, NULL, read_preference);
cursor->hint = server_id;
if (server_id > 0) {
cursor->hint = server_id;
}

if (!mongoc_cursor_next(cursor, &doc)) {
bson_error_t error;
Expand Down
40 changes: 4 additions & 36 deletions tests/readPreference/bug0146.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,12 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
["has_fields"]=>
bool(false)
["query"]=>
object(stdClass)#%d (2) {
object(stdClass)#%d (%d) {
["$query"]=>
object(stdClass)#%d (%d) {
["my"]=>
string(5) "query"
}
["$readPreference"]=>
object(stdClass)#%d (%d) {
["mode"]=>
string(16) "primaryPreferred"
["tags"]=>
array(0) {
}
}
}
["fields"]=>
object(stdClass)#%d (0) {
Expand Down Expand Up @@ -168,20 +160,12 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
["has_fields"]=>
bool(false)
["query"]=>
object(stdClass)#%d (2) {
object(stdClass)#%d (%d) {
["$query"]=>
object(stdClass)#%d (%d) {
["my"]=>
string(5) "query"
}
["$readPreference"]=>
object(stdClass)#%d (%d) {
["mode"]=>
string(9) "secondary"
["tags"]=>
array(0) {
}
}
}
["fields"]=>
object(stdClass)#%d (0) {
Expand Down Expand Up @@ -232,20 +216,12 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
["has_fields"]=>
bool(false)
["query"]=>
object(stdClass)#%d (2) {
object(stdClass)#%d (%d) {
["$query"]=>
object(stdClass)#%d (%d) {
["my"]=>
string(5) "query"
}
["$readPreference"]=>
object(stdClass)#%d (%d) {
["mode"]=>
string(18) "secondaryPreferred"
["tags"]=>
array(0) {
}
}
}
["fields"]=>
object(stdClass)#%d (0) {
Expand Down Expand Up @@ -296,20 +272,12 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
["has_fields"]=>
bool(false)
["query"]=>
object(stdClass)#%d (2) {
object(stdClass)#%d (%d) {
["$query"]=>
object(stdClass)#%d (%d) {
["my"]=>
string(5) "query"
}
["$readPreference"]=>
object(stdClass)#%d (%d) {
["mode"]=>
string(7) "nearest"
["tags"]=>
array(0) {
}
}
}
["fields"]=>
object(stdClass)#%d (0) {
Expand Down