@@ -105,25 +105,25 @@ PHP_METHOD(ReadPreference, __construct)
105
105
bson_destroy (tags );
106
106
}
107
107
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
+ }
124
124
}
125
125
126
- mongoc_read_prefs_set_max_staleness_ms (intern -> read_preference , maxStalenessMS );
126
+ mongoc_read_prefs_set_max_staleness_seconds (intern -> read_preference , maxStalenessSeconds );
127
127
}
128
128
129
129
if (!mongoc_read_prefs_is_valid (intern -> read_preference )) {
@@ -133,9 +133,9 @@ PHP_METHOD(ReadPreference, __construct)
133
133
}
134
134
/* }}} */
135
135
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 )
139
139
{
140
140
php_phongo_readpreference_t * intern ;
141
141
SUPPRESS_UNUSED_WARNING (return_value_ptr ) SUPPRESS_UNUSED_WARNING (return_value_used )
@@ -146,7 +146,7 @@ PHP_METHOD(ReadPreference, getMaxStalenessMS)
146
146
return ;
147
147
}
148
148
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 ));
150
150
}
151
151
/* }}} */
152
152
@@ -232,7 +232,7 @@ ZEND_END_ARG_INFO()
232
232
233
233
static zend_function_entry php_phongo_readpreference_me [] = {
234
234
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 )
236
236
PHP_ME (ReadPreference , getMode , ai_ReadPreference_void , ZEND_ACC_PUBLIC |ZEND_ACC_FINAL )
237
237
PHP_ME (ReadPreference , getTagSets , ai_ReadPreference_void , ZEND_ACC_PUBLIC |ZEND_ACC_FINAL )
238
238
PHP_ME (ReadPreference , bsonSerialize , ai_ReadPreference_void , ZEND_ACC_PUBLIC |ZEND_ACC_FINAL )
@@ -328,6 +328,8 @@ PHP_MINIT_FUNCTION(ReadPreference)
328
328
zend_declare_class_constant_long (php_phongo_readpreference_ce , ZEND_STRL ("RP_SECONDARY" ), MONGOC_READ_SECONDARY TSRMLS_CC );
329
329
zend_declare_class_constant_long (php_phongo_readpreference_ce , ZEND_STRL ("RP_SECONDARY_PREFERRED" ), MONGOC_READ_SECONDARY_PREFERRED TSRMLS_CC );
330
330
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 );
331
333
332
334
return SUCCESS ;
333
335
}
0 commit comments