31
31
#include "mongoc-bulk-operation-private.h"
32
32
#include "mongoc-read-concern-private.h"
33
33
#include "mongoc-write-concern-private.h"
34
- #include "mongoc-uri-private.h"
35
34
#include "mongoc-trace.h"
36
35
37
36
@@ -1637,14 +1636,14 @@ void php_phongo_populate_default_ssl_ctx(php_stream_context *ctx, zval *driverOp
1637
1636
#undef SET_STRING_CTX
1638
1637
} /* }}} */
1639
1638
1640
- static bool php_phongo_apply_rc_options_to_client ( mongoc_client_t * client , bson_t * options TSRMLS_DC ) /* {{{ */
1639
+ static bool php_phongo_apply_rc_options_to_uri ( mongoc_uri_t * uri , bson_t * options TSRMLS_DC ) /* {{{ */
1641
1640
{
1642
1641
bson_iter_t iter ;
1643
1642
mongoc_read_concern_t * new_rc ;
1644
1643
const mongoc_read_concern_t * old_rc ;
1645
1644
1646
- if (!(old_rc = mongoc_client_get_read_concern ( client ))) {
1647
- phongo_throw_exception (PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC , "Client does not have a read concern" );
1645
+ if (!(old_rc = mongoc_uri_get_read_concern ( uri ))) {
1646
+ phongo_throw_exception (PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC , "mongoc_uri_t does not have a read concern" );
1648
1647
1649
1648
return false;
1650
1649
}
@@ -1666,20 +1665,20 @@ static bool php_phongo_apply_rc_options_to_client(mongoc_client_t *client, bson_
1666
1665
mongoc_read_concern_set_level (new_rc , str );
1667
1666
}
1668
1667
1669
- mongoc_client_set_read_concern ( client , new_rc );
1668
+ mongoc_uri_set_read_concern ( uri , new_rc );
1670
1669
mongoc_read_concern_destroy (new_rc );
1671
1670
1672
1671
return true;
1673
1672
} /* }}} */
1674
1673
1675
- static bool php_phongo_apply_rp_options_to_client ( mongoc_client_t * client , bson_t * options TSRMLS_DC ) /* {{{ */
1674
+ static bool php_phongo_apply_rp_options_to_uri ( mongoc_uri_t * uri , bson_t * options TSRMLS_DC ) /* {{{ */
1676
1675
{
1677
1676
bson_iter_t iter ;
1678
1677
mongoc_read_prefs_t * new_rp ;
1679
1678
const mongoc_read_prefs_t * old_rp ;
1680
1679
1681
- if (!(old_rp = mongoc_client_get_read_prefs ( client ))) {
1682
- phongo_throw_exception (PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC , "Client does not have a read preference" );
1680
+ if (!(old_rp = mongoc_uri_get_read_prefs_t ( uri ))) {
1681
+ phongo_throw_exception (PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC , "mongoc_uri_t does not have a read preference" );
1683
1682
1684
1683
return false;
1685
1684
}
@@ -1751,21 +1750,21 @@ static bool php_phongo_apply_rp_options_to_client(mongoc_client_t *client, bson_
1751
1750
return false;
1752
1751
}
1753
1752
1754
- mongoc_client_set_read_prefs ( client , new_rp );
1753
+ mongoc_uri_set_read_prefs_t ( uri , new_rp );
1755
1754
mongoc_read_prefs_destroy (new_rp );
1756
1755
1757
1756
return true;
1758
1757
} /* }}} */
1759
1758
1760
- static bool php_phongo_apply_wc_options_to_client ( mongoc_client_t * client , bson_t * options TSRMLS_DC ) /* {{{ */
1759
+ static bool php_phongo_apply_wc_options_to_uri ( mongoc_uri_t * uri , bson_t * options TSRMLS_DC ) /* {{{ */
1761
1760
{
1762
1761
bson_iter_t iter ;
1763
1762
int32_t wtimeoutms ;
1764
1763
mongoc_write_concern_t * new_wc ;
1765
1764
const mongoc_write_concern_t * old_wc ;
1766
1765
1767
- if (!(old_wc = mongoc_client_get_write_concern ( client ))) {
1768
- phongo_throw_exception (PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC , "Client does not have a write concern" );
1766
+ if (!(old_wc = mongoc_uri_get_write_concern ( uri ))) {
1767
+ phongo_throw_exception (PHONGO_ERROR_MONGOC_FAILED TSRMLS_CC , "mongoc_uri_t does not have a write concern" );
1769
1768
1770
1769
return false;
1771
1770
}
@@ -1859,7 +1858,7 @@ static bool php_phongo_apply_wc_options_to_client(mongoc_client_t *client, bson_
1859
1858
return false;
1860
1859
}
1861
1860
1862
- mongoc_client_set_write_concern ( client , new_wc );
1861
+ mongoc_uri_set_write_concern ( uri , new_wc );
1863
1862
mongoc_write_concern_destroy (new_wc );
1864
1863
1865
1864
return true;
@@ -1986,6 +1985,13 @@ bool phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
1986
1985
return false;
1987
1986
}
1988
1987
1988
+ if (!php_phongo_apply_rc_options_to_uri (uri , bson_options TSRMLS_CC ) ||
1989
+ !php_phongo_apply_rp_options_to_uri (uri , bson_options TSRMLS_CC ) ||
1990
+ !php_phongo_apply_wc_options_to_uri (uri , bson_options TSRMLS_CC )) {
1991
+ /* Exception should already have been thrown */
1992
+ return false;
1993
+ }
1994
+
1989
1995
manager -> client = php_phongo_make_mongo_client (uri , driverOptions TSRMLS_CC );
1990
1996
mongoc_uri_destroy (uri );
1991
1997
@@ -1994,13 +2000,6 @@ bool phongo_manager_init(php_phongo_manager_t *manager, const char *uri_string,
1994
2000
return false;
1995
2001
}
1996
2002
1997
- if (!php_phongo_apply_rc_options_to_client (manager -> client , bson_options TSRMLS_CC ) ||
1998
- !php_phongo_apply_rp_options_to_client (manager -> client , bson_options TSRMLS_CC ) ||
1999
- !php_phongo_apply_wc_options_to_client (manager -> client , bson_options TSRMLS_CC )) {
2000
- /* Exception should already have been thrown */
2001
- return false;
2002
- }
2003
-
2004
2003
return true;
2005
2004
} /* }}} */
2006
2005
0 commit comments