@@ -1166,20 +1166,24 @@ static bool php_phongo_apply_rp_options_to_uri(mongoc_uri_t *uri, bson_t *option
1166
1166
1167
1167
/* Handle maxStalenessSeconds, and make sure it is not combined with primary
1168
1168
* readPreference */
1169
- if (bson_iter_init_find_case (& iter , options , MONGOC_URI_MAXSTALENESSSECONDS ) && BSON_ITER_HOLDS_INT32 (& iter )) {
1170
- int32_t max_staleness_seconds = bson_iter_int32 (& iter );
1169
+ if (bson_iter_init_find_case (& iter , options , MONGOC_URI_MAXSTALENESSSECONDS ) && BSON_ITER_HOLDS_INT (& iter )) {
1170
+ int64_t max_staleness_seconds = bson_iter_as_int64 (& iter );
1171
1171
1172
1172
if (max_staleness_seconds != MONGOC_NO_MAX_STALENESS ) {
1173
1173
1174
1174
if (max_staleness_seconds < MONGOC_SMALLEST_MAX_STALENESS_SECONDS ) {
1175
- phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Expected maxStalenessSeconds to be >= %d, %" PRId32 " given" , MONGOC_SMALLEST_MAX_STALENESS_SECONDS , max_staleness_seconds );
1175
+ phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Expected maxStalenessSeconds to be >= %d, %" PRId64 " given" , MONGOC_SMALLEST_MAX_STALENESS_SECONDS , max_staleness_seconds );
1176
1176
mongoc_read_prefs_destroy (new_rp );
1177
1177
1178
1178
return false;
1179
1179
}
1180
1180
1181
- /* max_staleness_seconds is fetched as an INT32, so there is no need to check
1182
- * if it exists INT32_MAX as we do in the ReadPreference constructor. */
1181
+ if (max_staleness_seconds > INT32_MAX ) {
1182
+ phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Expected maxStalenessSeconds to be <= %d, %" PRId64 " given" , INT32_MAX , max_staleness_seconds );
1183
+ mongoc_read_prefs_destroy (new_rp );
1184
+
1185
+ return false;
1186
+ }
1183
1187
1184
1188
if (mongoc_read_prefs_get_mode (new_rp ) == MONGOC_READ_PRIMARY ) {
1185
1189
phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Primary read preference mode conflicts with maxStalenessSeconds" );
0 commit comments