Skip to content

Commit 75fb5b3

Browse files
committed
PHPC-2548: Remove MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED
1 parent 74c217d commit 75fb5b3

File tree

6 files changed

+8
-48
lines changed

6 files changed

+8
-48
lines changed

src/MongoDB/WriteConcern.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static bool php_phongo_writeconcern_init_from_hash(php_phongo_writeconcern_t* in
8080

8181
if ((j = zend_hash_str_find(props, "j", sizeof("j") - 1))) {
8282
if (Z_TYPE_P(j) == IS_TRUE || Z_TYPE_P(j) == IS_FALSE) {
83-
if (zend_is_true(j) && (mongoc_write_concern_get_w(intern->write_concern) == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED || mongoc_write_concern_get_w(intern->write_concern) == MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED)) {
83+
if (zend_is_true(j) && (mongoc_write_concern_get_w(intern->write_concern) == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED)) {
8484
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Cannot enable journaling when using w = 0");
8585
goto failure;
8686
}
@@ -143,7 +143,7 @@ static PHP_METHOD(MongoDB_Driver_WriteConcern, __construct)
143143
switch (ZEND_NUM_ARGS()) {
144144
case 3:
145145
if (journal && Z_TYPE_P(journal) != IS_NULL) {
146-
if (zend_is_true(journal) && (mongoc_write_concern_get_w(intern->write_concern) == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED || mongoc_write_concern_get_w(intern->write_concern) == MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED)) {
146+
if (zend_is_true(journal) && (mongoc_write_concern_get_w(intern->write_concern) == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED)) {
147147
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Cannot enable journaling when using w = 0");
148148
return;
149149
}

src/phongo_client.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ static bool php_phongo_apply_wc_options_to_uri(mongoc_uri_t* uri, bson_t* option
595595
int32_t value = bson_iter_int32(&iter);
596596

597597
switch (value) {
598-
case MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED:
599598
case MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED:
600599
mongoc_write_concern_set_w(new_wc, value);
601600
break;
@@ -632,7 +631,7 @@ static bool php_phongo_apply_wc_options_to_uri(mongoc_uri_t* uri, bson_t* option
632631
if (mongoc_write_concern_get_journal(new_wc)) {
633632
int32_t w = mongoc_write_concern_get_w(new_wc);
634633

635-
if (w == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED || w == MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED) {
634+
if (w == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED) {
636635
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Journal conflicts with w value: %d", w);
637636
mongoc_write_concern_destroy(new_wc);
638637

tests/manager/manager-ctor-write_concern-001.phpt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ MongoDB\Driver\Manager::__construct(): write concern options (w)
44
<?php
55

66
$tests = [
7-
['mongodb://127.0.0.1/?w=-1', []],
87
['mongodb://127.0.0.1/?w=0', []],
98
['mongodb://127.0.0.1/?w=1', []],
109
['mongodb://127.0.0.1/?w=majority', []],
1110
['mongodb://127.0.0.1/?w=customTagSet', []],
12-
[null, ['w' => -1]],
1311
[null, ['w' => -0]],
1412
[null, ['w' => 1]],
1513
[null, ['w' => 'majority']],
@@ -27,10 +25,6 @@ foreach ($tests as $test) {
2725
===DONE===
2826
<?php exit(0); ?>
2927
--EXPECTF--
30-
object(MongoDB\Driver\WriteConcern)#%d (%d) {
31-
["w"]=>
32-
int(-1)
33-
}
3428
object(MongoDB\Driver\WriteConcern)#%d (%d) {
3529
["w"]=>
3630
int(0)
@@ -47,10 +41,6 @@ object(MongoDB\Driver\WriteConcern)#%d (%d) {
4741
["w"]=>
4842
string(12) "customTagSet"
4943
}
50-
object(MongoDB\Driver\WriteConcern)#%d (%d) {
51-
["w"]=>
52-
int(-1)
53-
}
5444
object(MongoDB\Driver\WriteConcern)#%d (%d) {
5545
["w"]=>
5646
int(0)

tests/manager/manager-ctor-write_concern-error-001.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ echo throws(function() {
1212
create_test_manager(null, ['w' => 1.0]);
1313
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
1414

15-
/* Note: Values of w < -1 are invalid, but libmongoc's URI string parsing only
15+
/* Note: Values of w < 0 are invalid, but libmongoc's URI string parsing only
1616
* logs a warning instead of raising an error (see: CDRIVER-2234), so we cannot
1717
* test for this. */
1818

1919
echo throws(function() {
20-
create_test_manager(null, ['w' => -2]);
20+
create_test_manager(null, ['w' => -1]);
2121
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
2222

2323
?>
@@ -27,5 +27,5 @@ echo throws(function() {
2727
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
2828
Expected 32-bit integer or string for "w" URI option, double given
2929
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
30-
Unsupported w value: -2
30+
Unsupported w value: -1
3131
===DONE===

tests/manager/manager-ctor-write_concern-error-005.phpt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,18 @@ echo throws(function() {
1717

1818
// Invalid values (journal conflicts with unacknowledged write concerns)
1919

20-
echo throws(function() {
21-
create_test_manager('mongodb://127.0.0.1/?w=-1&journal=true');
22-
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
23-
2420
echo throws(function() {
2521
create_test_manager('mongodb://127.0.0.1/?w=0&journal=true');
2622
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
2723

28-
echo throws(function() {
29-
create_test_manager('mongodb://127.0.0.1/?w=-1', ['journal' => true]);
30-
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
31-
3224
echo throws(function() {
3325
create_test_manager('mongodb://127.0.0.1/?w=0', ['journal' => true]);
3426
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
3527

36-
echo throws(function() {
37-
create_test_manager('mongodb://127.0.0.1/?journal=true', ['w' => -1]);
38-
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
39-
4028
echo throws(function() {
4129
create_test_manager('mongodb://127.0.0.1/?journal=true', ['w' => 0]);
4230
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
4331

44-
echo throws(function() {
45-
create_test_manager(null, ['w' => -1, 'journal' => true]);
46-
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
47-
4832
echo throws(function() {
4933
create_test_manager(null, ['w' => 0, 'journal' => true]);
5034
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n";
@@ -58,19 +42,11 @@ Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?journal=invalid'. Unsupported
5842
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5943
Expected boolean for "journal" URI option, string given
6044
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
61-
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?w=-1&journal=true'. Error while parsing the 'w' URI option: Journal conflicts with w value [w=-1].
62-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
6345
Failed to parse MongoDB URI: 'mongodb://127.0.0.1/?w=0&journal=true'. Error while parsing the 'w' URI option: Journal conflicts with w value [w=0].
6446
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
65-
Journal conflicts with w value: -1
66-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
6747
Journal conflicts with w value: 0
6848
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
69-
Journal conflicts with w value: -1
70-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
7149
Journal conflicts with w value: 0
7250
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
73-
Journal conflicts with w value: -1
74-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
7551
Journal conflicts with w value: 0
7652
===DONE===

tests/writeConcern/writeconcern-isdefault-001.phpt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,14 @@ $tests = [
1414
new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY),
1515
// mongoc_uri_parse_option() ignores empty string for w
1616
(new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w='))->getWriteConcern(),
17-
// Cannot test "w=-3" since libmongoc URI parsing expects integers >= -1
18-
// Cannot test "w=-2" since libmongoc URI parsing expects integers >= -1, and throws an error otherwise
19-
(new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w=-1'))->getWriteConcern(),
17+
// Cannot test "w=-3", "w=-2", and "w=-1" since libmongoc URI parsing expects integers > -1
2018
(new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w=0'))->getWriteConcern(),
2119
(new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w=1'))->getWriteConcern(),
2220
(new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w=2'))->getWriteConcern(),
2321
(new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w=tag'))->getWriteConcern(),
2422
(new MongoDB\Driver\Manager('mongodb://127.0.0.1/?w=majority'))->getWriteConcern(),
2523
// Cannot test ['w' => null] since an integer or string type is expected (PHPC-887)
26-
// Cannot test ['w' => -3] or ['w' => -2] since php_phongo_apply_wc_options_to_uri() expects integers >= -1
27-
(new MongoDB\Driver\Manager(null, ['w' => -1]))->getWriteConcern(),
24+
// Cannot test ['w' => -3], ['w' => -2], and ['w' => -1] since php_phongo_apply_wc_options_to_uri() expects integers > -1
2825
(new MongoDB\Driver\Manager(null, ['w' => 0]))->getWriteConcern(),
2926
(new MongoDB\Driver\Manager(null, ['w' => 1]))->getWriteConcern(),
3027
(new MongoDB\Driver\Manager(null, ['w' => 2]))->getWriteConcern(),
@@ -60,7 +57,5 @@ bool(false)
6057
bool(false)
6158
bool(false)
6259
bool(false)
63-
bool(false)
64-
bool(false)
6560
bool(true)
6661
===DONE===

0 commit comments

Comments
 (0)