Skip to content

Commit 43b06f0

Browse files
committed
PHPC-827: Update Max Staleness implementation
1 parent c729150 commit 43b06f0

15 files changed

+126
-93
lines changed

php_phongo.c

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,8 @@ void php_phongo_read_preference_to_zval(zval *retval, const mongoc_read_prefs_t
914914
#endif
915915
}
916916

917-
if (mongoc_read_prefs_get_max_staleness_ms(read_prefs) != 0) {
918-
ADD_ASSOC_LONG_EX(retval, "maxStalenessMS", mongoc_read_prefs_get_max_staleness_ms(read_prefs));
917+
if (mongoc_read_prefs_get_max_staleness_seconds(read_prefs) != MONGOC_NO_MAX_STALENESS) {
918+
ADD_ASSOC_LONG_EX(retval, "maxStalenessSeconds", mongoc_read_prefs_get_max_staleness_seconds(read_prefs));
919919
}
920920
} /* }}} */
921921

@@ -971,7 +971,7 @@ static mongoc_uri_t *php_phongo_make_uri(const char *uri_string, bson_t *options
971971
!strcasecmp(key, "slaveok") ||
972972
!strcasecmp(key, "w") ||
973973
!strcasecmp(key, "wtimeoutms") ||
974-
!strcasecmp(key, "maxstalenessms") ||
974+
!strcasecmp(key, "maxstalenessseconds") ||
975975
!strcasecmp(key, "appname")
976976
) {
977977
continue;
@@ -1060,7 +1060,7 @@ static bool php_phongo_apply_rp_options_to_uri(mongoc_uri_t *uri, bson_t *option
10601060
if (!bson_iter_init_find_case(&iter, options, "slaveok") &&
10611061
!bson_iter_init_find_case(&iter, options, "readpreference") &&
10621062
!bson_iter_init_find_case(&iter, options, "readpreferencetags") &&
1063-
!bson_iter_init_find_case(&iter, options, "maxstalenessms")
1063+
!bson_iter_init_find_case(&iter, options, "maxstalenessseconds")
10641064
) {
10651065
return true;
10661066
}
@@ -1124,29 +1124,32 @@ static bool php_phongo_apply_rp_options_to_uri(mongoc_uri_t *uri, bson_t *option
11241124
return false;
11251125
}
11261126

1127-
/* Handle maxStalenessMS, and make sure it is not combined with primary
1127+
/* Handle maxStalenessSeconds, and make sure it is not combined with primary
11281128
* readPreference */
1129-
if (bson_iter_init_find_case(&iter, options, "maxstalenessms") && BSON_ITER_HOLDS_INT32(&iter)) {
1130-
int32_t max_staleness_ms = bson_iter_int32(&iter);
1129+
if (bson_iter_init_find_case(&iter, options, "maxstalenessseconds") && BSON_ITER_HOLDS_INT32(&iter)) {
1130+
int32_t max_staleness_seconds = bson_iter_int32(&iter);
11311131

1132-
if (max_staleness_ms < 0) {
1133-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessMS to be >= 0, %" PRId32 " given", max_staleness_ms);
1134-
mongoc_read_prefs_destroy(new_rp);
1132+
if (max_staleness_seconds != MONGOC_NO_MAX_STALENESS) {
11351133

1136-
return false;
1137-
}
1134+
if (max_staleness_seconds < MONGOC_SMALLEST_MAX_STALENESS_SECONDS) {
1135+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessSeconds to be >= %d, %" PRId32 " given", MONGOC_SMALLEST_MAX_STALENESS_SECONDS, max_staleness_seconds);
1136+
mongoc_read_prefs_destroy(new_rp);
1137+
1138+
return false;
1139+
}
11381140

1139-
/* max_staleness_ms is fetched as an INT32, so there is no need to check
1140-
* if it exists INT32_MAX as we do in the ReadPreference constructor. */
1141+
/* max_staleness_seconds is fetched as an INT32, so there is no need to check
1142+
* if it exists INT32_MAX as we do in the ReadPreference constructor. */
11411143

1142-
if (mongoc_read_prefs_get_mode(new_rp) == MONGOC_READ_PRIMARY) {
1143-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Primary read preference mode conflicts with maxStalenessMS");
1144-
mongoc_read_prefs_destroy(new_rp);
1144+
if (mongoc_read_prefs_get_mode(new_rp) == MONGOC_READ_PRIMARY) {
1145+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Primary read preference mode conflicts with maxStalenessSeconds");
1146+
mongoc_read_prefs_destroy(new_rp);
11451147

1146-
return false;
1148+
return false;
1149+
}
11471150
}
11481151

1149-
mongoc_read_prefs_set_max_staleness_ms(new_rp, max_staleness_ms);
1152+
mongoc_read_prefs_set_max_staleness_seconds(new_rp, max_staleness_seconds);
11501153
}
11511154

11521155
/* This may be redundant in light of the last check (primary with tags), but

src/MongoDB/ReadPreference.c

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,25 @@ PHP_METHOD(ReadPreference, __construct)
105105
bson_destroy(tags);
106106
}
107107

108-
if (options && php_array_exists(options, "maxStalenessMS")) {
109-
phongo_long maxStalenessMS = php_array_fetchc_long(options, "maxStalenessMS");
110-
111-
if (maxStalenessMS < 0) {
112-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessMS to be >= 0, %" PHONGO_LONG_FORMAT " given", maxStalenessMS);
113-
return;
114-
}
115-
116-
if (maxStalenessMS > INT32_MAX) {
117-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessMS to be <= %" PRId32 ", %" PHONGO_LONG_FORMAT " given", INT32_MAX, maxStalenessMS);
118-
return;
119-
}
120-
121-
if (maxStalenessMS > 0 && mode == MONGOC_READ_PRIMARY) {
122-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "maxStalenessMS may not be used with primary mode");
123-
return;
108+
if (options && php_array_exists(options, "maxStalenessSeconds")) {
109+
phongo_long maxStalenessSeconds = php_array_fetchc_long(options, "maxStalenessSeconds");
110+
111+
if (maxStalenessSeconds != MONGOC_NO_MAX_STALENESS) {
112+
if (maxStalenessSeconds < MONGOC_SMALLEST_MAX_STALENESS_SECONDS) {
113+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessSeconds to be >= %d, %" PHONGO_LONG_FORMAT " given", MONGOC_SMALLEST_MAX_STALENESS_SECONDS, maxStalenessSeconds);
114+
return;
115+
}
116+
if (maxStalenessSeconds > INT32_MAX) {
117+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessSeconds to be <= %" PRId32 ", %" PHONGO_LONG_FORMAT " given", INT32_MAX, maxStalenessSeconds);
118+
return;
119+
}
120+
if (mode == MONGOC_READ_PRIMARY) {
121+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "maxStalenessSeconds may not be used with primary mode");
122+
return;
123+
}
124124
}
125125

126-
mongoc_read_prefs_set_max_staleness_ms(intern->read_preference, maxStalenessMS);
126+
mongoc_read_prefs_set_max_staleness_seconds(intern->read_preference, maxStalenessSeconds);
127127
}
128128

129129
if (!mongoc_read_prefs_is_valid(intern->read_preference)) {
@@ -133,9 +133,9 @@ PHP_METHOD(ReadPreference, __construct)
133133
}
134134
/* }}} */
135135

136-
/* {{{ proto integer ReadPreference::getMaxStalenessMS()
137-
Returns the ReadPreference maxStalenessMS value */
138-
PHP_METHOD(ReadPreference, getMaxStalenessMS)
136+
/* {{{ proto integer ReadPreference::getMaxStalenessSeconds()
137+
Returns the ReadPreference maxStalenessSeconds value */
138+
PHP_METHOD(ReadPreference, getMaxStalenessSeconds)
139139
{
140140
php_phongo_readpreference_t *intern;
141141
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
@@ -146,7 +146,7 @@ PHP_METHOD(ReadPreference, getMaxStalenessMS)
146146
return;
147147
}
148148

149-
RETURN_LONG(mongoc_read_prefs_get_max_staleness_ms(intern->read_preference));
149+
RETURN_LONG(mongoc_read_prefs_get_max_staleness_seconds(intern->read_preference));
150150
}
151151
/* }}} */
152152

@@ -232,7 +232,7 @@ ZEND_END_ARG_INFO()
232232

233233
static zend_function_entry php_phongo_readpreference_me[] = {
234234
PHP_ME(ReadPreference, __construct, ai_ReadPreference___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
235-
PHP_ME(ReadPreference, getMaxStalenessMS, ai_ReadPreference_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
235+
PHP_ME(ReadPreference, getMaxStalenessSeconds, ai_ReadPreference_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
236236
PHP_ME(ReadPreference, getMode, ai_ReadPreference_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
237237
PHP_ME(ReadPreference, getTagSets, ai_ReadPreference_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
238238
PHP_ME(ReadPreference, bsonSerialize, ai_ReadPreference_void, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
@@ -328,6 +328,8 @@ PHP_MINIT_FUNCTION(ReadPreference)
328328
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_SECONDARY"), MONGOC_READ_SECONDARY TSRMLS_CC);
329329
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_SECONDARY_PREFERRED"), MONGOC_READ_SECONDARY_PREFERRED TSRMLS_CC);
330330
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_NEAREST"), MONGOC_READ_NEAREST TSRMLS_CC);
331+
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("NO_MAX_STALENESS"), MONGOC_NO_MAX_STALENESS TSRMLS_CC);
332+
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("SMALLEST_MAX_STALENESS_SECONDS"), MONGOC_SMALLEST_MAX_STALENESS_SECONDS TSRMLS_CC);
331333

332334
return SUCCESS;
333335
}

src/libmongoc

Submodule libmongoc updated 189 files

tests/manager/manager-ctor-read_preference-001.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ MongoDB\Driver\Manager::__construct(): read preference options
66
$tests = [
77
['mongodb://127.0.0.1/?readPreference=primary', []],
88
['mongodb://127.0.0.1/?readPreference=secondary&readPreferenceTags=tag:one&readPreferenceTags=', []],
9-
['mongodb://127.0.0.1/?readPreference=secondary&maxStalenessMS=1000', []],
9+
['mongodb://127.0.0.1/?readPreference=secondary&maxStalenessSeconds=1000', []],
1010
[null, ['readPreference' => 'primary']],
1111
[null, ['readPreference' => 'secondary', 'readPreferenceTags' => [['tag' => 'one'], []]]],
12-
[null, ['readPreference' => 'secondary', 'maxStalenessMS' => 1000]],
12+
[null, ['readPreference' => 'secondary', 'maxStalenessSeconds' => 1000]],
1313
];
1414

1515
foreach ($tests as $test) {
@@ -45,7 +45,7 @@ object(MongoDB\Driver\ReadPreference)#%d (%d) {
4545
object(MongoDB\Driver\ReadPreference)#%d (%d) {
4646
["mode"]=>
4747
string(9) "secondary"
48-
["maxStalenessMS"]=>
48+
["maxStalenessSeconds"]=>
4949
int(1000)
5050
}
5151
object(MongoDB\Driver\ReadPreference)#%d (%d) {
@@ -70,7 +70,7 @@ object(MongoDB\Driver\ReadPreference)#%d (%d) {
7070
object(MongoDB\Driver\ReadPreference)#%d (%d) {
7171
["mode"]=>
7272
string(9) "secondary"
73-
["maxStalenessMS"]=>
73+
["maxStalenessSeconds"]=>
7474
int(1000)
7575
}
7676
===DONE===
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
--TEST--
2-
MongoDB\Driver\Manager::__construct(): read preference options (maxStalenessMS)
2+
MongoDB\Driver\Manager::__construct(): read preference options (maxStalenessSeconds)
33
--FILE--
44
<?php
55

66
$tests = [
7-
['mongodb://127.0.0.1/?readPreference=secondary&maxStalenessMS=1231', []],
8-
['mongodb://127.0.0.1/?readPreference=secondary', ['maxStalenessMS' => 1231]],
9-
['mongodb://127.0.0.1/?readPreference=secondary&maxStalenessMS=1000', ['maxStalenessMS' => 2000]],
10-
['mongodb://127.0.0.1/?readpreference=secondary&maxstalenessms=1231', []],
11-
['mongodb://127.0.0.1/?readpreference=secondary', ['maxstalenessms' => 1231]],
7+
['mongodb://127.0.0.1/?readPreference=secondary&maxStalenessSeconds=1231', []],
8+
['mongodb://127.0.0.1/?readPreference=secondary', ['maxStalenessSeconds' => 1231]],
9+
['mongodb://127.0.0.1/?readPreference=secondary&maxStalenessSeconds=1000', ['maxStalenessSeconds' => 2000]],
10+
['mongodb://127.0.0.1/?readpreference=secondary&maxstalenessseconds=1231', []],
11+
['mongodb://127.0.0.1/?readpreference=secondary', ['maxstalenessseconds' => 1231]],
1212
];
1313

1414
foreach ($tests as $test) {
@@ -24,31 +24,31 @@ foreach ($tests as $test) {
2424
object(MongoDB\Driver\ReadPreference)#%d (%d) {
2525
["mode"]=>
2626
string(9) "secondary"
27-
["maxStalenessMS"]=>
27+
["maxStalenessSeconds"]=>
2828
int(1231)
2929
}
3030
object(MongoDB\Driver\ReadPreference)#%d (%d) {
3131
["mode"]=>
3232
string(9) "secondary"
33-
["maxStalenessMS"]=>
33+
["maxStalenessSeconds"]=>
3434
int(1231)
3535
}
3636
object(MongoDB\Driver\ReadPreference)#%d (%d) {
3737
["mode"]=>
3838
string(9) "secondary"
39-
["maxStalenessMS"]=>
39+
["maxStalenessSeconds"]=>
4040
int(2000)
4141
}
4242
object(MongoDB\Driver\ReadPreference)#%d (%d) {
4343
["mode"]=>
4444
string(9) "secondary"
45-
["maxStalenessMS"]=>
45+
["maxStalenessSeconds"]=>
4646
int(1231)
4747
}
4848
object(MongoDB\Driver\ReadPreference)#%d (%d) {
4949
["mode"]=>
5050
string(9) "secondary"
51-
["maxStalenessMS"]=>
51+
["maxStalenessSeconds"]=>
5252
int(1231)
5353
}
5454
===DONE===

tests/manager/manager-ctor-read_preference-003.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MongoDB\Driver\Manager::__construct(): read preference options of the wrong type
66
$tests = [
77
['mongodb://127.0.0.1/?readPreference=secondary', ['readPreference' => 1]],
88
['mongodb://127.0.0.1/?readPreference=secondary&readPreferenceTags=tag:one', ['readPreferenceTags' => 'invalid']],
9-
['mongodb://127.0.0.1/?readPreference=secondary&maxStalenessMS=1000', ['maxStalenessMS' => 'invalid']],
9+
['mongodb://127.0.0.1/?readPreference=secondary&maxStalenessSeconds=1000', ['maxStalenessSeconds' => 'invalid']],
1010
];
1111

1212
foreach ($tests as $test) {
@@ -38,7 +38,7 @@ object(MongoDB\Driver\ReadPreference)#%d (%d) {
3838
object(MongoDB\Driver\ReadPreference)#%d (%d) {
3939
["mode"]=>
4040
string(9) "secondary"
41-
["maxStalenessMS"]=>
41+
["maxStalenessSeconds"]=>
4242
int(1000)
4343
}
4444
===DONE===
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,54 @@
11
--TEST--
2-
MongoDB\Driver\Manager::__construct(): invalid read preference (maxStalenessMS)
2+
MongoDB\Driver\Manager::__construct(): invalid read preference (maxStalenesSeconds)
33
--FILE--
44
<?php
55

66
require_once __DIR__ . '/../utils/tools.php';
77

88
echo throws(function() {
9-
$manager = new MongoDB\Driver\Manager('mongodb://127.0.0.1/?maxstalenessms=1231');
9+
$manager = new MongoDB\Driver\Manager('mongodb://127.0.0.1/?maxstalenessseconds=1231');
1010
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
1111

1212
echo throws(function() {
13-
$manager = new MongoDB\Driver\Manager('mongodb://127.0.0.1/?maxStalenessMS=1231');
13+
$manager = new MongoDB\Driver\Manager('mongodb://127.0.0.1/?maxStalenessSeconds=1231');
1414
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
1515

1616
echo throws(function() {
17-
$manager = new MongoDB\Driver\Manager(null, ['maxstalenessms' => 1231]);
17+
$manager = new MongoDB\Driver\Manager(null, ['maxstalenessseconds' => 1231]);
1818
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
1919

2020
echo throws(function() {
21-
$manager = new MongoDB\Driver\Manager(null, ['maxStalenessMS' => 1231]);
21+
$manager = new MongoDB\Driver\Manager(null, ['maxStalenessSeconds' => 1231]);
2222
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
2323

2424
echo throws(function() {
25-
$manager = new MongoDB\Driver\Manager(null, ['readPreference' => 'secondary', 'maxStalenessMS' => -1]);
25+
$manager = new MongoDB\Driver\Manager(null, ['readPreference' => 'secondary', 'maxStalenessSeconds' => -2]);
26+
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
27+
28+
echo throws(function() {
29+
$manager = new MongoDB\Driver\Manager(null, ['readPreference' => 'secondary', 'maxStalenessSeconds' => 0]);
30+
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
31+
32+
echo throws(function() {
33+
$manager = new MongoDB\Driver\Manager(null, ['readPreference' => 'secondary', 'maxStalenessSeconds' => 42]);
2634
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
2735

2836
?>
2937
===DONE===
3038
<?php exit(0); ?>
3139
--EXPECTF--
3240
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
33-
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?maxstalenessms=1231'
41+
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?maxstalenessseconds=1231'
42+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
43+
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?maxStalenessSeconds=1231'
44+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
45+
Primary read preference mode conflicts with maxStalenessSeconds
3446
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
35-
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?maxStalenessMS=1231'
47+
Primary read preference mode conflicts with maxStalenessSeconds
3648
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
37-
Primary read preference mode conflicts with maxStalenessMS
49+
Expected maxStalenessSeconds to be >= 90, -2 given
3850
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
39-
Primary read preference mode conflicts with maxStalenessMS
51+
Expected maxStalenessSeconds to be >= 90, 0 given
4052
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
41-
Expected maxStalenessMS to be >= 0, -1 given
53+
Expected maxStalenessSeconds to be >= 90, 42 given
4254
===DONE===

tests/readPreference/readpreference-bsonserialize-001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $tests = [
1414
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY, []),
1515
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, [['dc' => 'ny']]),
1616
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, [['dc' => 'ny'], ['dc' => 'sf', 'use' => 'reporting'], []]),
17-
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, ['maxStalenessMS' => 1000]),
17+
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, ['maxStalenessSeconds' => 1000]),
1818
];
1919

2020
foreach ($tests as $test) {
@@ -33,5 +33,5 @@ foreach ($tests as $test) {
3333
{ "mode" : "primary" }
3434
{ "mode" : "secondary", "tags" : [ { "dc" : "ny" } ] }
3535
{ "mode" : "secondary", "tags" : [ { "dc" : "ny" }, { "dc" : "sf", "use" : "reporting" }, { } ] }
36-
{ "mode" : "secondary", "maxStalenessMS" : 1000 }
36+
{ "mode" : "secondary", "maxStalenessSeconds" : 1000 }
3737
===DONE===

tests/readPreference/readpreference-bsonserialize-002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $tests = [
1414
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY, []),
1515
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, [['dc' => 'ny']]),
1616
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, [['dc' => 'ny'], ['dc' => 'sf', 'use' => 'reporting'], []]),
17-
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, ['maxStalenessMS' => 1000]),
17+
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, ['maxStalenessSeconds' => 1000]),
1818
];
1919

2020
foreach ($tests as $test) {
@@ -86,7 +86,7 @@ object(stdClass)#%d (%d) {
8686
object(stdClass)#%d (%d) {
8787
["mode"]=>
8888
string(9) "secondary"
89-
["maxStalenessMS"]=>
89+
["maxStalenessSeconds"]=>
9090
int(1000)
9191
}
9292
===DONE===

tests/readPreference/readpreference-ctor-001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MongoDB\Driver\ReadPreference construction
66
var_dump(new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY));
77
var_dump(new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, [['tag' => 'one']]));
88
var_dump(new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY, []));
9-
var_dump(new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, ['maxStalenessMS' => 1000]));
9+
var_dump(new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, ['maxStalenessSeconds' => 1000]));
1010

1111
?>
1212
===DONE===
@@ -35,7 +35,7 @@ object(MongoDB\Driver\ReadPreference)#%d (%d) {
3535
object(MongoDB\Driver\ReadPreference)#%d (%d) {
3636
["mode"]=>
3737
string(9) "secondary"
38-
["maxStalenessMS"]=>
38+
["maxStalenessSeconds"]=>
3939
int(1000)
4040
}
4141
===DONE===

0 commit comments

Comments
 (0)