Skip to content

Commit 4523f55

Browse files
committed
Merge pull request #288
2 parents 19d2655 + 749f6d2 commit 4523f55

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

php_phongo.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "bson.h"
2929
#include "mongoc.h"
3030
#include "mongoc-cursor-cursorid-private.h"
31-
#include "mongoc-read-prefs-private.h"
3231
#include "mongoc-bulk-operation-private.h"
3332
#include "mongoc-read-concern-private.h"
3433
#include "mongoc-write-concern-private.h"
@@ -1367,17 +1366,19 @@ void php_phongo_read_concern_to_zval(zval *retval, const mongoc_read_concern_t *
13671366

13681367
void php_phongo_read_preference_to_zval(zval *retval, const mongoc_read_prefs_t *read_prefs) /* {{{ */
13691368
{
1369+
const bson_t *tags = mongoc_read_prefs_get_tags(read_prefs);
13701370

13711371
array_init_size(retval, 2);
13721372

1373-
ADD_ASSOC_LONG_EX(retval, "mode", read_prefs->mode);
1374-
if (read_prefs->tags.len) {
1373+
ADD_ASSOC_LONG_EX(retval, "mode", mongoc_read_prefs_get_mode(read_prefs));
1374+
1375+
if (tags->len) {
13751376
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
13761377
/* Use native arrays for debugging output */
13771378
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
13781379
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
13791380

1380-
phongo_bson_to_zval_ex(bson_get_data(&read_prefs->tags), read_prefs->tags.len, &state);
1381+
phongo_bson_to_zval_ex(bson_get_data(tags), tags->len, &state);
13811382
#if PHP_VERSION_ID >= 70000
13821383
ADD_ASSOC_ZVAL_EX(retval, "tags", &state.zchild);
13831384
#else

src/MongoDB/ReadPreference.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
/* External libs */
2828
#include <bson.h>
2929
#include <mongoc.h>
30-
#include <mongoc-read-prefs-private.h>
3130

3231
/* PHP Core stuff */
3332
#include <php.h>
@@ -117,6 +116,7 @@ PHP_METHOD(ReadPreference, getMode)
117116
PHP_METHOD(ReadPreference, getTagSets)
118117
{
119118
php_phongo_readpreference_t *intern;
119+
const bson_t *tags;
120120
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
121121

122122
intern = Z_READPREFERENCE_OBJ_P(getThis());
@@ -125,13 +125,15 @@ PHP_METHOD(ReadPreference, getTagSets)
125125
return;
126126
}
127127

128-
if (intern->read_preference->tags.len) {
128+
tags = mongoc_read_prefs_get_tags(intern->read_preference);
129+
130+
if (tags->len) {
129131
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
130132
/* Use native arrays for debugging output */
131133
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
132134
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
133135

134-
phongo_bson_to_zval_ex(bson_get_data(&intern->read_preference->tags), intern->read_preference->tags.len, &state);
136+
phongo_bson_to_zval_ex(bson_get_data(tags), tags->len, &state);
135137
#if PHP_VERSION_ID >= 70000
136138
RETURN_ZVAL(&state.zchild, 0, 1);
137139
#else

0 commit comments

Comments
 (0)