Skip to content

Commit a612c37

Browse files
authored
PHPC-1756: Remove oppressive terminology from source code (#1221)
* Use latest version of libmongoc * Remove deprecated terminology for primary * Remove deprecated terminology for secondary * Fix clang-format * Remove check for legacy field * Fix missing space in error expectation * Harden test expectation around primary checks
1 parent 0da4042 commit a612c37

19 files changed

+39
-194
lines changed

php_phongo.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,8 +1164,8 @@ php_phongo_server_description_type_t php_phongo_server_description_type(mongoc_s
11641164

11651165
bool php_phongo_server_to_zval(zval* retval, mongoc_server_description_t* sd) /* {{{ */
11661166
{
1167-
mongoc_host_list_t* host = mongoc_server_description_host(sd);
1168-
const bson_t* is_master = mongoc_server_description_ismaster(sd);
1167+
mongoc_host_list_t* host = mongoc_server_description_host(sd);
1168+
const bson_t* hello_response = mongoc_server_description_hello_response(sd);
11691169
bson_iter_t iter;
11701170

11711171
array_init(retval);
@@ -1176,10 +1176,10 @@ bool php_phongo_server_to_zval(zval* retval, mongoc_server_description_t* sd) /*
11761176
ADD_ASSOC_BOOL_EX(retval, "is_primary", !strcmp(mongoc_server_description_type(sd), php_phongo_server_description_type_map[PHONGO_SERVER_RS_PRIMARY].name));
11771177
ADD_ASSOC_BOOL_EX(retval, "is_secondary", !strcmp(mongoc_server_description_type(sd), php_phongo_server_description_type_map[PHONGO_SERVER_RS_SECONDARY].name));
11781178
ADD_ASSOC_BOOL_EX(retval, "is_arbiter", !strcmp(mongoc_server_description_type(sd), php_phongo_server_description_type_map[PHONGO_SERVER_RS_ARBITER].name));
1179-
ADD_ASSOC_BOOL_EX(retval, "is_hidden", bson_iter_init_find_case(&iter, is_master, "hidden") && bson_iter_as_bool(&iter));
1180-
ADD_ASSOC_BOOL_EX(retval, "is_passive", bson_iter_init_find_case(&iter, is_master, "passive") && bson_iter_as_bool(&iter));
1179+
ADD_ASSOC_BOOL_EX(retval, "is_hidden", bson_iter_init_find_case(&iter, hello_response, "hidden") && bson_iter_as_bool(&iter));
1180+
ADD_ASSOC_BOOL_EX(retval, "is_passive", bson_iter_init_find_case(&iter, hello_response, "passive") && bson_iter_as_bool(&iter));
11811181

1182-
if (bson_iter_init_find(&iter, is_master, "tags") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
1182+
if (bson_iter_init_find(&iter, hello_response, "tags") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
11831183
const uint8_t* bytes;
11841184
uint32_t len;
11851185
php_phongo_bson_state state;
@@ -1199,12 +1199,12 @@ bool php_phongo_server_to_zval(zval* retval, mongoc_server_description_t* sd) /*
11991199

12001200
PHONGO_BSON_INIT_DEBUG_STATE(state);
12011201

1202-
if (!php_phongo_bson_to_zval_ex(bson_get_data(is_master), is_master->len, &state)) {
1202+
if (!php_phongo_bson_to_zval_ex(bson_get_data(hello_response), hello_response->len, &state)) {
12031203
zval_ptr_dtor(&state.zchild);
12041204
return false;
12051205
}
12061206

1207-
ADD_ASSOC_ZVAL_EX(retval, "last_is_master", &state.zchild);
1207+
ADD_ASSOC_ZVAL_EX(retval, "last_hello_response", &state.zchild);
12081208
}
12091209
ADD_ASSOC_LONG_EX(retval, "round_trip_time", (zend_long) mongoc_server_description_round_trip_time(sd));
12101210

@@ -1553,7 +1553,6 @@ static bool php_phongo_apply_options_to_uri(mongoc_uri_t* uri, bson_t* options)
15531553
!strcasecmp(key, MONGOC_URI_READPREFERENCE) ||
15541554
!strcasecmp(key, MONGOC_URI_READPREFERENCETAGS) ||
15551555
!strcasecmp(key, MONGOC_URI_SAFE) ||
1556-
!strcasecmp(key, MONGOC_URI_SLAVEOK) ||
15571556
!strcasecmp(key, MONGOC_URI_W) ||
15581557
!strcasecmp(key, MONGOC_URI_WTIMEOUTMS)) {
15591558

@@ -1793,7 +1792,6 @@ static bool php_phongo_apply_rp_options_to_uri(mongoc_uri_t* uri, bson_t* option
17931792
bson_iter_t iter;
17941793
mongoc_read_prefs_t* new_rp;
17951794
const mongoc_read_prefs_t* old_rp;
1796-
bool ignore_slaveok = false;
17971795

17981796
if (!(old_rp = mongoc_uri_get_read_prefs_t(uri))) {
17991797
phongo_throw_exception(PHONGO_ERROR_MONGOC_FAILED, "mongoc_uri_t does not have a read preference");
@@ -1811,19 +1809,6 @@ static bool php_phongo_apply_rp_options_to_uri(mongoc_uri_t* uri, bson_t* option
18111809
while (bson_iter_next(&iter)) {
18121810
const char* key = bson_iter_key(&iter);
18131811

1814-
if (!ignore_slaveok && !strcasecmp(key, MONGOC_URI_SLAVEOK)) {
1815-
if (!BSON_ITER_HOLDS_BOOL(&iter)) {
1816-
PHONGO_URI_INVALID_TYPE(iter, "boolean");
1817-
mongoc_read_prefs_destroy(new_rp);
1818-
1819-
return false;
1820-
}
1821-
1822-
if (bson_iter_bool(&iter)) {
1823-
mongoc_read_prefs_set_mode(new_rp, MONGOC_READ_SECONDARY_PREFERRED);
1824-
}
1825-
}
1826-
18271812
if (!strcasecmp(key, MONGOC_URI_READPREFERENCE)) {
18281813
const char* str;
18291814

@@ -1852,8 +1837,6 @@ static bool php_phongo_apply_rp_options_to_uri(mongoc_uri_t* uri, bson_t* option
18521837

18531838
return false;
18541839
}
1855-
1856-
ignore_slaveok = true;
18571840
}
18581841

18591842
if (!strcasecmp(key, MONGOC_URI_READPREFERENCETAGS)) {

src/LIBMONGOC_VERSION_CURRENT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.18.0-20210426+git724f1672f2
1+
1.18.0-20210622+gitebe90917f2

src/MongoDB/Server.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,10 @@ static PHP_METHOD(Server, getTags)
263263
zend_restore_error_handling(&error_handling);
264264

265265
if ((sd = mongoc_client_get_server_description(Z_MANAGER_OBJ_P(&intern->manager)->client, intern->server_id))) {
266-
const bson_t* is_master = mongoc_server_description_ismaster(sd);
266+
const bson_t* hello_response = mongoc_server_description_hello_response(sd);
267267
bson_iter_t iter;
268268

269-
if (bson_iter_init_find(&iter, is_master, "tags") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
269+
if (bson_iter_init_find(&iter, hello_response, "tags") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
270270
const uint8_t* bytes;
271271
uint32_t len;
272272
php_phongo_bson_state state;
@@ -295,7 +295,7 @@ static PHP_METHOD(Server, getTags)
295295
} /* }}} */
296296

297297
/* {{{ proto array MongoDB\Driver\Server::getInfo()
298-
Returns the last isMaster result document for this Server */
298+
Returns the last hello response for this Server */
299299
static PHP_METHOD(Server, getInfo)
300300
{
301301
zend_error_handling error_handling;
@@ -312,12 +312,12 @@ static PHP_METHOD(Server, getInfo)
312312
zend_restore_error_handling(&error_handling);
313313

314314
if ((sd = mongoc_client_get_server_description(Z_MANAGER_OBJ_P(&intern->manager)->client, intern->server_id))) {
315-
const bson_t* is_master = mongoc_server_description_ismaster(sd);
315+
const bson_t* hello_response = mongoc_server_description_hello_response(sd);
316316
php_phongo_bson_state state;
317317

318318
PHONGO_BSON_INIT_DEBUG_STATE(state);
319319

320-
if (!php_phongo_bson_to_zval_ex(bson_get_data(is_master), is_master->len, &state)) {
320+
if (!php_phongo_bson_to_zval_ex(bson_get_data(hello_response), hello_response->len, &state)) {
321321
/* Exception should already have been thrown */
322322
zval_ptr_dtor(&state.zchild);
323323
mongoc_server_description_destroy(sd);
@@ -508,7 +508,7 @@ static PHP_METHOD(Server, isHidden)
508508
if ((sd = mongoc_client_get_server_description(Z_MANAGER_OBJ_P(&intern->manager)->client, intern->server_id))) {
509509
bson_iter_t iter;
510510

511-
RETVAL_BOOL(bson_iter_init_find_case(&iter, mongoc_server_description_ismaster(sd), "hidden") && bson_iter_as_bool(&iter));
511+
RETVAL_BOOL(bson_iter_init_find_case(&iter, mongoc_server_description_hello_response(sd), "hidden") && bson_iter_as_bool(&iter));
512512
mongoc_server_description_destroy(sd);
513513
return;
514514
}
@@ -536,7 +536,7 @@ static PHP_METHOD(Server, isPassive)
536536
if ((sd = mongoc_client_get_server_description(Z_MANAGER_OBJ_P(&intern->manager)->client, intern->server_id))) {
537537
bson_iter_t iter;
538538

539-
RETVAL_BOOL(bson_iter_init_find_case(&iter, mongoc_server_description_ismaster(sd), "passive") && bson_iter_as_bool(&iter));
539+
RETVAL_BOOL(bson_iter_init_find_case(&iter, mongoc_server_description_hello_response(sd), "passive") && bson_iter_as_bool(&iter));
540540
mongoc_server_description_destroy(sd);
541541
return;
542542
}

src/libmongoc

Submodule libmongoc updated 656 files

tests/connect/standalone-ssl-verify_cert-error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname"
2828

2929
Deprecated: MongoDB\Driver\Manager::__construct(): The "weak_cert_validation" driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
3030
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException thrown from executeCommand
31-
No suitable servers found (`serverSelectionTryOnce` set): [%s calling ismaster on '%s:%d']
31+
No suitable servers found (`serverSelectionTryOnce` set): [%s calling %s on '%s:%d']
3232
===DONE===

tests/connect/standalone-ssl-verify_cert-error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname"
3434

3535
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_self_signed" context driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
3636
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException thrown from executeCommand
37-
No suitable servers found (`serverSelectionTryOnce` set): [%s calling ismaster on '%s:%d']
37+
No suitable servers found (`serverSelectionTryOnce` set): [%s calling %s on '%s:%d']
3838
===DONE===

tests/manager/manager-ctor-read_preference-004.phpt

Lines changed: 0 additions & 114 deletions
This file was deleted.

tests/manager/manager-ctor-read_preference-error-003.phpt

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/manager/manager-set-uri-options-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Deprecated: MongoDB\Driver\Manager::__construct(): The "context" driver option i
5050

5151
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_self_signed" context driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
5252
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException
53-
No suitable servers found (`serverSelectionTryOnce` set): [%scalling ismaster on '%s']
53+
No suitable servers found (`serverSelectionTryOnce` set): [%s calling %s on '%s']
5454

5555
Deprecated: MongoDB\Driver\Manager::__construct(): The "context" driver option is deprecated.%s
5656

tests/manager/manager-var-dump-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object(MongoDB\Driver\Manager)#%d (%d) {
5252
bool(false)
5353
["is_passive"]=>
5454
bool(false)
55-
["last_is_master"]=>
55+
["last_hello_response"]=>
5656
array(%d) {
5757
%a
5858
}

tests/ocsp-failure.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ $m->executeCommand('admin', $ping);
2929
<?php exit(0); ?>
3030
--EXPECTF--
3131
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException
32-
No suitable servers found (`serverSelectionTryOnce` set): [%s calling ismaster on '%s:%d']
32+
No suitable servers found (`serverSelectionTryOnce` set): [%s calling %s on '%s:%d']
3333
===DONE===

tests/replicaset/manager-getservers-001.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ array(3) {
4646
bool(false)
4747
["is_passive"]=>
4848
bool(false)%A
49-
["last_is_master"]=>
49+
["last_hello_response"]=>
5050
array(%d) {
5151
%a
5252
}
@@ -71,7 +71,7 @@ array(3) {
7171
bool(false)
7272
["is_passive"]=>
7373
bool(false)%A
74-
["last_is_master"]=>
74+
["last_hello_response"]=>
7575
array(%d) {
7676
%a
7777
}
@@ -96,7 +96,7 @@ array(3) {
9696
bool(false)
9797
["is_passive"]=>
9898
bool(false)
99-
["last_is_master"]=>
99+
["last_hello_response"]=>
100100
array(%d) {
101101
%a
102102
}

tests/replicaset/server-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var_dump(
4040
$server->isHidden(),
4141
$server->isPassive()
4242
);
43-
$info = $server->getInfo(); // isMaster output changes between mongod versions
43+
$info = $server->getInfo(); // hello response changes between mongod versions
4444
var_dump($info["setName"], $info["hosts"]);
4545
var_dump($info["me"] == $server->getHost() . ":" . $server->getPort());
4646
?>

tests/replicaset/server-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var_dump(
3535
$server->isHidden(),
3636
$server->isPassive()
3737
);
38-
$info = $server->getInfo(); // isMaster output changes between mongod versions
38+
$info = $server->getInfo(); // hello response changes between mongod versions
3939
var_dump($info["setName"], $info["hosts"]);
4040
var_dump($info["me"] == $server->getHost() . ":" . $server->getPort());
4141
?>

tests/server/server-debug.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ object(MongoDB\Driver\Server)#%d (%d) {
3434
bool(false)
3535
["is_passive"]=>
3636
bool(false)%A
37-
["last_is_master"]=>
37+
["last_hello_response"]=>
3838
array(%d) {
3939
%a
4040
}

0 commit comments

Comments
 (0)