@@ -203,17 +203,21 @@ static bool php_phongo_query_init_limit_and_singlebatch(php_phongo_query_t* inte
203
203
* which must be converted to a mongoc_read_concern_t. */
204
204
static bool php_phongo_query_init_readconcern (php_phongo_query_t * intern , zval * options TSRMLS_DC ) /* {{{ */
205
205
{
206
- if (php_array_existsc (options , "readConcern" )) {
207
- zval * read_concern = php_array_fetchc (options , "readConcern" );
206
+ zval * read_concern ;
208
207
209
- if (Z_TYPE_P (read_concern ) != IS_OBJECT || !instanceof_function (Z_OBJCE_P (read_concern ), php_phongo_readconcern_ce TSRMLS_CC )) {
210
- phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Expected \"readConcern\" option to be %s, %s given" , ZSTR_VAL (php_phongo_readconcern_ce -> name ), PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P (read_concern ));
211
- return false;
212
- }
208
+ if (!php_array_existsc (options , "readConcern" )) {
209
+ return true;
210
+ }
211
+
212
+ read_concern = php_array_fetchc (options , "readConcern" );
213
213
214
- intern -> read_concern = mongoc_read_concern_copy (phongo_read_concern_from_zval (read_concern TSRMLS_CC ));
214
+ if (Z_TYPE_P (read_concern ) != IS_OBJECT || !instanceof_function (Z_OBJCE_P (read_concern ), php_phongo_readconcern_ce TSRMLS_CC )) {
215
+ phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Expected \"readConcern\" option to be %s, %s given" , ZSTR_VAL (php_phongo_readconcern_ce -> name ), PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P (read_concern ));
216
+ return false;
215
217
}
216
218
219
+ intern -> read_concern = mongoc_read_concern_copy (phongo_read_concern_from_zval (read_concern TSRMLS_CC ));
220
+
217
221
return true;
218
222
} /* }}} */
219
223
@@ -224,22 +228,26 @@ static bool php_phongo_query_init_readconcern(php_phongo_query_t* intern, zval*
224
228
* via mongoc_cursor_set_max_await_time_ms(). */
225
229
static bool php_phongo_query_init_max_await_time_ms (php_phongo_query_t * intern , zval * options TSRMLS_DC ) /* {{{ */
226
230
{
227
- if (php_array_existsc (options , "maxAwaitTimeMS" )) {
228
- int64_t max_await_time_ms = php_array_fetchc_long (options , "maxAwaitTimeMS" );
231
+ int64_t max_await_time_ms ;
229
232
230
- if (max_await_time_ms < 0 ) {
231
- phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Expected \"maxAwaitTimeMS\" option to be >= 0, %" PRId64 " given" , max_await_time_ms );
232
- return false;
233
- }
233
+ if (!php_array_existsc (options , "maxAwaitTimeMS" )) {
234
+ return true;
235
+ }
234
236
235
- if (max_await_time_ms > UINT32_MAX ) {
236
- phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Expected \"maxAwaitTimeMS\" option to be <= %" PRIu32 ", %" PRId64 " given" , UINT32_MAX , max_await_time_ms );
237
- return false;
238
- }
237
+ max_await_time_ms = php_array_fetchc_long (options , "maxAwaitTimeMS" );
239
238
240
- intern -> max_await_time_ms = (uint32_t ) max_await_time_ms ;
239
+ if (max_await_time_ms < 0 ) {
240
+ phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Expected \"maxAwaitTimeMS\" option to be >= 0, %" PRId64 " given" , max_await_time_ms );
241
+ return false;
241
242
}
242
243
244
+ if (max_await_time_ms > UINT32_MAX ) {
245
+ phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Expected \"maxAwaitTimeMS\" option to be <= %" PRIu32 ", %" PRId64 " given" , UINT32_MAX , max_await_time_ms );
246
+ return false;
247
+ }
248
+
249
+ intern -> max_await_time_ms = (uint32_t ) max_await_time_ms ;
250
+
243
251
return true;
244
252
} /* }}} */
245
253
0 commit comments