You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if ((maxStalenessSeconds=zend_hash_str_find(props, "maxStalenessSeconds", sizeof("maxStalenessSeconds") -1))) {
93
93
if (Z_TYPE_P(maxStalenessSeconds) ==IS_LONG) {
94
-
if (Z_LVAL_P(maxStalenessSeconds) <MONGOC_SMALLEST_MAX_STALENESS_SECONDS) {
95
-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"maxStalenessSeconds\" integer field to be >= %d", ZSTR_VAL(php_phongo_readpreference_ce->name), MONGOC_SMALLEST_MAX_STALENESS_SECONDS);
96
-
goto failure;
94
+
if (Z_LVAL_P(maxStalenessSeconds) !=MONGOC_NO_MAX_STALENESS) {
95
+
if (mongoc_read_prefs_get_mode(intern->read_preference) ==MONGOC_READ_PRIMARY) {
96
+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"maxStalenessSeconds\" field to not be present with \"primary\" mode", ZSTR_VAL(php_phongo_readpreference_ce->name));
97
+
goto failure;
98
+
}
99
+
if (Z_LVAL_P(maxStalenessSeconds) <MONGOC_SMALLEST_MAX_STALENESS_SECONDS) {
100
+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"maxStalenessSeconds\" integer field to be >= %d", ZSTR_VAL(php_phongo_readpreference_ce->name), MONGOC_SMALLEST_MAX_STALENESS_SECONDS);
101
+
goto failure;
102
+
}
103
+
if (Z_LVAL_P(maxStalenessSeconds) >INT32_MAX) {
104
+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"maxStalenessSeconds\" integer field to be <= %"PRId32, ZSTR_VAL(php_phongo_readpreference_ce->name), INT32_MAX);
105
+
goto failure;
106
+
}
97
107
}
98
-
if (Z_LVAL_P(maxStalenessSeconds) >INT32_MAX) {
99
-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"maxStalenessSeconds\" integer field to be <= %"PRId32, ZSTR_VAL(php_phongo_readpreference_ce->name), INT32_MAX);
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"maxStalenessSeconds\" field to be integer", ZSTR_VAL(php_phongo_readpreference_ce->name));
112
+
goto failure;
113
+
}
114
+
}
115
+
116
+
if ((hedge=zend_hash_str_find(props, "hedge", sizeof("hedge") -1))) {
117
+
if (Z_TYPE_P(hedge) ==IS_ARRAY||Z_TYPE_P(hedge) ==IS_OBJECT) {
118
+
bson_t*hedge_doc=bson_new();
119
+
120
+
if (mongoc_read_prefs_get_mode(intern->read_preference) ==MONGOC_READ_PRIMARY) {
121
+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"hedge\" field to not be present with \"primary\" mode", ZSTR_VAL(php_phongo_readpreference_ce->name));
122
+
bson_destroy(hedge_doc);
100
123
goto failure;
101
124
}
102
-
if (mongoc_read_prefs_get_mode(intern->read_preference) ==MONGOC_READ_PRIMARY) {
103
-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"maxStalenessSeconds\" array field to not be present with \"primary\" mode", ZSTR_VAL(php_phongo_readpreference_ce->name));
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"maxStalenessSeconds\" field to be integer", ZSTR_VAL(php_phongo_readpreference_ce->name));
136
+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"hedge\" field to be an array or object", ZSTR_VAL(php_phongo_readpreference_ce->name));
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "%s initialization requires \"hedge\" field to be an array or object", ZSTR_VAL(php_phongo_readpreference_ce->name));
291
+
return;
292
+
}
293
+
}
294
+
241
295
if (!mongoc_read_prefs_is_valid(intern->read_preference)) {
242
296
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Read preference is not valid");
0 commit comments