Skip to content

PHPC-1756: Remove oppressive terminology from source code #1221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions php_phongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,8 +1164,8 @@ php_phongo_server_description_type_t php_phongo_server_description_type(mongoc_s

bool php_phongo_server_to_zval(zval* retval, mongoc_server_description_t* sd) /* {{{ */
{
mongoc_host_list_t* host = mongoc_server_description_host(sd);
const bson_t* is_master = mongoc_server_description_ismaster(sd);
mongoc_host_list_t* host = mongoc_server_description_host(sd);
const bson_t* hello_response = mongoc_server_description_hello_response(sd);
bson_iter_t iter;

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

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

PHONGO_BSON_INIT_DEBUG_STATE(state);

if (!php_phongo_bson_to_zval_ex(bson_get_data(is_master), is_master->len, &state)) {
if (!php_phongo_bson_to_zval_ex(bson_get_data(hello_response), hello_response->len, &state)) {
zval_ptr_dtor(&state.zchild);
return false;
}

ADD_ASSOC_ZVAL_EX(retval, "last_is_master", &state.zchild);
ADD_ASSOC_ZVAL_EX(retval, "last_hello_response", &state.zchild);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we never documented the returned fields, I decided to drop the old field entirely. Let me know if you think we should keep it in for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just used for debug output, since Manager and Server are not serializable. No objections to changing this, since we don't document debug output at all.

}
ADD_ASSOC_LONG_EX(retval, "round_trip_time", (zend_long) mongoc_server_description_round_trip_time(sd));

Expand Down Expand Up @@ -1553,7 +1553,6 @@ static bool php_phongo_apply_options_to_uri(mongoc_uri_t* uri, bson_t* options)
!strcasecmp(key, MONGOC_URI_READPREFERENCE) ||
!strcasecmp(key, MONGOC_URI_READPREFERENCETAGS) ||
!strcasecmp(key, MONGOC_URI_SAFE) ||
!strcasecmp(key, MONGOC_URI_SLAVEOK) ||
!strcasecmp(key, MONGOC_URI_W) ||
!strcasecmp(key, MONGOC_URI_WTIMEOUTMS)) {

Expand Down Expand Up @@ -1793,7 +1792,6 @@ static bool php_phongo_apply_rp_options_to_uri(mongoc_uri_t* uri, bson_t* option
bson_iter_t iter;
mongoc_read_prefs_t* new_rp;
const mongoc_read_prefs_t* old_rp;
bool ignore_slaveok = false;

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

if (!ignore_slaveok && !strcasecmp(key, MONGOC_URI_SLAVEOK)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See PHPC-1836

if (!BSON_ITER_HOLDS_BOOL(&iter)) {
PHONGO_URI_INVALID_TYPE(iter, "boolean");
mongoc_read_prefs_destroy(new_rp);

return false;
}

if (bson_iter_bool(&iter)) {
mongoc_read_prefs_set_mode(new_rp, MONGOC_READ_SECONDARY_PREFERRED);
}
}

if (!strcasecmp(key, MONGOC_URI_READPREFERENCE)) {
const char* str;

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

return false;
}

ignore_slaveok = true;
}

if (!strcasecmp(key, MONGOC_URI_READPREFERENCETAGS)) {
Expand Down
2 changes: 1 addition & 1 deletion src/LIBMONGOC_VERSION_CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.18.0-20210426+git724f1672f2
1.18.0-20210622+gitebe90917f2
14 changes: 7 additions & 7 deletions src/MongoDB/Server.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ static PHP_METHOD(Server, getTags)
zend_restore_error_handling(&error_handling);

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

if (bson_iter_init_find(&iter, is_master, "tags") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
if (bson_iter_init_find(&iter, hello_response, "tags") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
const uint8_t* bytes;
uint32_t len;
php_phongo_bson_state state;
Expand Down Expand Up @@ -295,7 +295,7 @@ static PHP_METHOD(Server, getTags)
} /* }}} */

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

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

PHONGO_BSON_INIT_DEBUG_STATE(state);

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

RETVAL_BOOL(bson_iter_init_find_case(&iter, mongoc_server_description_ismaster(sd), "hidden") && bson_iter_as_bool(&iter));
RETVAL_BOOL(bson_iter_init_find_case(&iter, mongoc_server_description_hello_response(sd), "hidden") && bson_iter_as_bool(&iter));
mongoc_server_description_destroy(sd);
return;
}
Expand Down Expand Up @@ -536,7 +536,7 @@ static PHP_METHOD(Server, isPassive)
if ((sd = mongoc_client_get_server_description(Z_MANAGER_OBJ_P(&intern->manager)->client, intern->server_id))) {
bson_iter_t iter;

RETVAL_BOOL(bson_iter_init_find_case(&iter, mongoc_server_description_ismaster(sd), "passive") && bson_iter_as_bool(&iter));
RETVAL_BOOL(bson_iter_init_find_case(&iter, mongoc_server_description_hello_response(sd), "passive") && bson_iter_as_bool(&iter));
mongoc_server_description_destroy(sd);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc
Submodule libmongoc updated 656 files
2 changes: 1 addition & 1 deletion tests/connect/standalone-ssl-verify_cert-error-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname"

Deprecated: MongoDB\Driver\Manager::__construct(): The "weak_cert_validation" driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException thrown from executeCommand
No suitable servers found (`serverSelectionTryOnce` set): [%s calling ismaster on '%s:%d']
No suitable servers found (`serverSelectionTryOnce` set): [%s calling %s on '%s:%d']
===DONE===
2 changes: 1 addition & 1 deletion tests/connect/standalone-ssl-verify_cert-error-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname"

Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_self_signed" context driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException thrown from executeCommand
No suitable servers found (`serverSelectionTryOnce` set): [%s calling ismaster on '%s:%d']
No suitable servers found (`serverSelectionTryOnce` set): [%s calling %s on '%s:%d']
===DONE===
114 changes: 0 additions & 114 deletions tests/manager/manager-ctor-read_preference-004.phpt

This file was deleted.

24 changes: 0 additions & 24 deletions tests/manager/manager-ctor-read_preference-error-003.phpt

This file was deleted.

2 changes: 1 addition & 1 deletion tests/manager/manager-set-uri-options-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Deprecated: MongoDB\Driver\Manager::__construct(): The "context" driver option i

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

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

Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-var-dump-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object(MongoDB\Driver\Manager)#%d (%d) {
bool(false)
["is_passive"]=>
bool(false)
["last_is_master"]=>
["last_hello_response"]=>
array(%d) {
%a
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ocsp-failure.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ $m->executeCommand('admin', $ping);
<?php exit(0); ?>
--EXPECTF--
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException
No suitable servers found (`serverSelectionTryOnce` set): [%s calling ismaster on '%s:%d']
No suitable servers found (`serverSelectionTryOnce` set): [%s calling %s on '%s:%d']
===DONE===
6 changes: 3 additions & 3 deletions tests/replicaset/manager-getservers-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ array(3) {
bool(false)
["is_passive"]=>
bool(false)%A
["last_is_master"]=>
["last_hello_response"]=>
array(%d) {
%a
}
Expand All @@ -71,7 +71,7 @@ array(3) {
bool(false)
["is_passive"]=>
bool(false)%A
["last_is_master"]=>
["last_hello_response"]=>
array(%d) {
%a
}
Expand All @@ -96,7 +96,7 @@ array(3) {
bool(false)
["is_passive"]=>
bool(false)
["last_is_master"]=>
["last_hello_response"]=>
array(%d) {
%a
}
Expand Down
2 changes: 1 addition & 1 deletion tests/replicaset/server-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var_dump(
$server->isHidden(),
$server->isPassive()
);
$info = $server->getInfo(); // isMaster output changes between mongod versions
$info = $server->getInfo(); // hello response changes between mongod versions
var_dump($info["setName"], $info["hosts"]);
var_dump($info["me"] == $server->getHost() . ":" . $server->getPort());
?>
Expand Down
2 changes: 1 addition & 1 deletion tests/replicaset/server-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var_dump(
$server->isHidden(),
$server->isPassive()
);
$info = $server->getInfo(); // isMaster output changes between mongod versions
$info = $server->getInfo(); // hello response changes between mongod versions
var_dump($info["setName"], $info["hosts"]);
var_dump($info["me"] == $server->getHost() . ":" . $server->getPort());
?>
Expand Down
2 changes: 1 addition & 1 deletion tests/server/server-debug.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object(MongoDB\Driver\Server)#%d (%d) {
bool(false)
["is_passive"]=>
bool(false)%A
["last_is_master"]=>
["last_hello_response"]=>
array(%d) {
%a
}
Expand Down
Loading