@@ -1634,6 +1634,41 @@ void php_phongo_populate_default_ssl_ctx(php_stream_context *ctx, zval *driverOp
1634
1634
#undef SET_STRING_CTX
1635
1635
} /* }}} */
1636
1636
1637
+ static bool php_phongo_apply_rc_options_to_client (mongoc_client_t * client , bson_t * options TSRMLS_DC ) /* {{{ */
1638
+ {
1639
+ bson_iter_t iter ;
1640
+ mongoc_read_concern_t * new_rc ;
1641
+ const mongoc_read_concern_t * old_rc ;
1642
+
1643
+ if (!(old_rc = mongoc_client_get_read_concern (client ))) {
1644
+ phongo_throw_exception (PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC , "Client does not have a read concern" );
1645
+
1646
+ return false;
1647
+ }
1648
+
1649
+ /* Return early if there are no options to apply */
1650
+ if (bson_empty0 (options )) {
1651
+ return true;
1652
+ }
1653
+
1654
+ if (!bson_iter_init_find_case (& iter , options , "readconcernlevel" )) {
1655
+ return true;
1656
+ }
1657
+
1658
+ new_rc = mongoc_read_concern_copy (old_rc );
1659
+
1660
+ if (bson_iter_init_find_case (& iter , options , "readconcernlevel" ) && BSON_ITER_HOLDS_UTF8 (& iter )) {
1661
+ const char * str = bson_iter_utf8 (& iter , NULL );
1662
+
1663
+ mongoc_read_concern_set_level (new_rc , str );
1664
+ }
1665
+
1666
+ mongoc_client_set_read_concern (client , new_rc );
1667
+ mongoc_read_concern_destroy (new_rc );
1668
+
1669
+ return true;
1670
+ } /* }}} */
1671
+
1637
1672
static bool php_phongo_apply_rp_options_to_client (mongoc_client_t * client , bson_t * options TSRMLS_DC ) /* {{{ */
1638
1673
{
1639
1674
bson_iter_t iter ;
@@ -1956,7 +1991,8 @@ bool phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
1956
1991
return false;
1957
1992
}
1958
1993
1959
- if (!php_phongo_apply_rp_options_to_client (manager -> client , bson_options TSRMLS_CC ) ||
1994
+ if (!php_phongo_apply_rc_options_to_client (manager -> client , bson_options TSRMLS_CC ) ||
1995
+ !php_phongo_apply_rp_options_to_client (manager -> client , bson_options TSRMLS_CC ) ||
1960
1996
!php_phongo_apply_wc_options_to_client (manager -> client , bson_options TSRMLS_CC )) {
1961
1997
/* Exception should already have been thrown */
1962
1998
return false;
0 commit comments