Skip to content

Commit 754e934

Browse files
authored
PHPC-2489: Deprecate passing WriteConcern and ReadPreference objects to execute methods (#1770)
* Prefer writeConcern and readPreference options for execute methods * Correctly use Server method in server-executeQuery-010.phpt The original test incorrectly called the Manager method. This dates back to 87fbd00.
1 parent 7590fae commit 754e934

39 files changed

+103
-38
lines changed

src/phongo_util.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ zval* php_phongo_prep_legacy_option(zval* options, const char* key, bool* alloca
9292
Z_ADDREF_P(options);
9393
*allocated = true;
9494

95+
php_error_docref(NULL, E_DEPRECATED, "Passing the \"%s\" option directly is deprecated and will be removed in ext-mongodb 2.0", key);
96+
9597
return new_options;
9698
}
9799

tests/bulk/write-0002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $w = 1;
2121
$wtimeout = 1000;
2222
$writeConcern = new \MongoDB\Driver\WriteConcern($w, $wtimeout);
2323
var_dump($insertBulk);
24-
$result = $manager->executeBulkWrite(NS, $insertBulk, $writeConcern);
24+
$result = $manager->executeBulkWrite(NS, $insertBulk, ['writeConcern' => $writeConcern]);
2525
var_dump($insertBulk);
2626

2727
assert($result instanceof \MongoDB\Driver\WriteResult);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
MongoDB\Driver\Manager::executeBulkWrite() explicit WriteConcern argument is deprecated
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_live(); ?>
6+
<?php skip_if_not_clean(); ?>
7+
--FILE--
8+
<?php
9+
10+
require_once __DIR__ . "/../utils/basic.inc";
11+
12+
$manager = create_test_manager();
13+
14+
$bulk = new MongoDB\Driver\BulkWrite();
15+
$bulk->insert(['_id' => 1]);
16+
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
17+
18+
?>
19+
===DONE===
20+
<?php exit(0); ?>
21+
--EXPECTF--
22+
Deprecated: MongoDB\Driver\Manager::executeBulkWrite(): Passing the "writeConcern" option directly is deprecated and will be removed in ext-mongodb 2.0%s
23+
===DONE===

tests/manager/manager-executeBulkWrite_error-003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $bulk = new MongoDB\Driver\BulkWrite();
1414
$bulk->insert(array('_id' => 1, 'x' => 1));
1515

1616
try {
17-
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(30));
17+
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(30)]);
1818
} catch (MongoDB\Driver\Exception\BulkWriteException $e) {
1919
printf("BulkWriteException: %s\n", $e->getMessage());
2020

tests/manager/manager-executeCommand-003.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
3232
<?php exit(0); ?>
3333
--EXPECTF--
3434
Testing primary:
35+
36+
Deprecated: MongoDB\Driver\Manager::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
3537
is_primary: true
3638
is_secondary: false
3739

3840
Testing secondary:
41+
42+
Deprecated: MongoDB\Driver\Manager::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
3943
is_primary: false
4044
is_secondary: true
4145

tests/manager/manager-executeQuery-004.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
3737
<?php exit(0); ?>
3838
--EXPECTF--
3939
Testing primary:
40+
41+
Deprecated: MongoDB\Driver\Manager::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4042
is_primary: true
4143
is_secondary: false
4244

4345
Testing secondary:
46+
47+
Deprecated: MongoDB\Driver\Manager::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4448
is_primary: false
4549
is_secondary: true
4650

tests/readPreference/bug0146-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $rps = [
2626

2727
foreach($rps as $r) {
2828
$rp = new MongoDB\Driver\ReadPreference($r);
29-
$cursor = $manager->executeQuery(NS, new MongoDB\Driver\Query(array("my" => "query")), $rp);
29+
$cursor = $manager->executeQuery(NS, new MongoDB\Driver\Query(['my' => 'query']), ['readPreference' => $rp]);
3030
var_dump($cursor);
3131
}
3232

tests/replicaset/bug0155.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $bulk = new MongoDB\Driver\BulkWrite();
1515
$bulk->insert(array('example' => 'document'));
1616

1717
try {
18-
$manager->executeBulkWrite(NS, $bulk, $wc);
18+
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]);
1919
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
2020
var_dump($e->getWriteResult()->getWriteConcernError());
2121
}

tests/replicaset/readconcern-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $wc = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY);
1515
$bulk = new MongoDB\Driver\BulkWrite();
1616
$bulk->insert(['_id' => 1, 'x' => 1]);
1717
$bulk->insert(['_id' => 2, 'x' => 2]);
18-
$manager->executeBulkWrite(NS, $bulk, $wc);
18+
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]);
1919

2020
$rc = new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::LOCAL);
2121
$query = new MongoDB\Driver\Query(['x' => 2], ['readConcern' => $rc]);

tests/replicaset/writeconcernerror-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $bulk->insert(array("my" => "value"));
1515

1616
$w = new MongoDB\Driver\WriteConcern(30, 100);
1717
try {
18-
$retval = $manager->executeBulkWrite(NS, $bulk, $w);
18+
$retval = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $w]);
1919
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
2020
$server = $e->getWriteResult()->getServer();
2121
$server->getPort();

tests/replicaset/writeconcernerror-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $bulk->update(array("foo" => "bar"), array('$set' => array("foo" => "baz")), arr
2121

2222
$w = new MongoDB\Driver\WriteConcern(30);
2323
try {
24-
$retval = $manager->executeBulkWrite(NS, $bulk, $w);
24+
$retval = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $w]);
2525
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
2626
printWriteResult($e->getWriteResult(), false);
2727
}

tests/replicaset/writeresult-getserver-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var_dump($server == $server2);
3030

3131
$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::SECONDARY);
3232
/* Fetch a secondary */
33-
$server3 = $manager->executeQuery(NS, new MongoDB\Driver\Query(array()), $rp)->getServer();
33+
$server3 = $manager->executeQuery(NS, new MongoDB\Driver\Query([]), ['readPreference' => $rp])->getServer();
3434

3535
var_dump($server == $server3);
3636
var_dump($server->getPort(), $server3->getPort());

tests/replicaset/writeresult-getserver-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var_dump($server == $server2);
3333

3434
$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::SECONDARY);
3535
/* Fetch a secondary */
36-
$server3 = $manager->executeQuery(NS, new MongoDB\Driver\Query(array()), $rp)->getServer();
36+
$server3 = $manager->executeQuery(NS, new MongoDB\Driver\Query([]), ['readPreference' => $rp])->getServer();
3737

3838
var_dump($server == $server3);
3939
var_dump($server->getPort(), $server3->getPort());

tests/server/server-executeBulkWrite-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ foreach ($writeConcerns as $writeConcern) {
1717
$bulk = new MongoDB\Driver\BulkWrite();
1818
$bulk->insert(array('wc' => $writeConcern));
1919

20-
$result = $primary->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($writeConcern));
20+
$result = $primary->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($writeConcern)]);
2121
var_dump($result->isAcknowledged());
2222
var_dump($result->getInsertedCount());
2323
}

tests/server/server-executeBulkWrite-003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ foreach ($writeConcerns as $wc) {
1818
$bulk = new MongoDB\Driver\BulkWrite();
1919
$bulk->insert(array('wc' => $wc));
2020

21-
$result = $server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($wc));
21+
$result = $server->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($wc)]);
2222
var_dump($result->isAcknowledged());
2323
var_dump($result->getInsertedCount());
2424
}

tests/server/server-executeBulkWrite-004.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ foreach ($writeConcerns as $wc) {
2121
$bulk->insert(array('wc' => $wc));
2222

2323
echo throws(function() use ($server, $bulk, $wc) {
24-
$server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($wc));
24+
$server->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($wc)]);
2525
}, "MongoDB\Driver\Exception\RuntimeException"), "\n";
2626
}
2727

tests/server/server-executeBulkWrite-005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ foreach ($writeConcerns as $wc) {
2323
$bulk = new MongoDB\Driver\BulkWrite();
2424
$bulk->insert(array('wc' => $wc));
2525

26-
$result = $server->executeBulkWrite('local.' . COLLECTION_NAME, $bulk, new MongoDB\Driver\WriteConcern($wc));
26+
$result = $server->executeBulkWrite('local.' . COLLECTION_NAME, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($wc)]);
2727
var_dump($result->isAcknowledged());
2828
var_dump($result->getInsertedCount());
2929
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
MongoDB\Driver\Server::executeBulkWrite() explicit WriteConcern argument is deprecated
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_live(); ?>
6+
<?php skip_if_not_clean(); ?>
7+
--FILE--
8+
<?php
9+
10+
require_once __DIR__ . "/../utils/basic.inc";
11+
12+
$manager = create_test_manager();
13+
$server = $manager->selectServer();
14+
15+
$bulk = new MongoDB\Driver\BulkWrite();
16+
$bulk->insert(['_id' => 1]);
17+
$server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
18+
19+
?>
20+
===DONE===
21+
<?php exit(0); ?>
22+
--EXPECTF--
23+
Deprecated: MongoDB\Driver\Server::executeBulkWrite(): Passing the "writeConcern" option directly is deprecated and will be removed in ext-mongodb 2.0%s
24+
===DONE===

tests/server/server-executeCommand-002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $command = new MongoDB\Driver\Command([
2525
'pipeline' => [ [ '$match' => [ 'x' => 1 ] ] ],
2626
'cursor' => (object) [],
2727
]);
28-
$secondary->executeCommand(DATABASE_NAME, $command, $rp);
28+
$secondary->executeCommand(DATABASE_NAME, $command, ['readPreference' => $rp]);
2929

3030
$query = new MongoDB\Driver\Query(
3131
array(
@@ -37,7 +37,7 @@ $query = new MongoDB\Driver\Query(
3737
'limit' => 1,
3838
)
3939
);
40-
$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, $rp);
40+
$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, ['readPreference' => $rp]);
4141
$profileEntry = current($cursor->toArray());
4242

4343
var_dump($profileEntry->command);

tests/server/server-executeCommand-003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $secondary = $manager->selectServer($secondaryRp);
1717
* no effect when directly querying a server, since the secondaryOk flag is always
1818
* set for hinted commands. */
1919
$primaryRp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::PRIMARY);
20-
$cursor = $secondary->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(array('ping' => 1)), $primaryRp);
20+
$cursor = $secondary->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(array('ping' => 1)), ['readPreference' => $primaryRp]);
2121

2222
var_dump($cursor->toArray());
2323

tests/server/server-executeCommand-005.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
3535
<?php exit(0); ?>
3636
--EXPECTF--
3737
Testing primary:
38+
39+
Deprecated: MongoDB\Driver\Server::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
3840
is_primary: true
3941
is_secondary: false
4042

4143
Testing secondary:
44+
45+
Deprecated: MongoDB\Driver\Server::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4246
is_primary: false
4347
is_secondary: true
4448

tests/server/server-executeQuery-006.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (empty($result->ok)) {
2424
exit("Could not set profile level\n");
2525
}
2626

27-
$secondary->executeQuery(NS, new MongoDB\Driver\Query(array("x" => 1)), $rp);
27+
$secondary->executeQuery(NS, new MongoDB\Driver\Query(['x' => 1]), ['readPreference' => $rp]);
2828

2929
$query = new MongoDB\Driver\Query(
3030
array(
@@ -36,7 +36,7 @@ $query = new MongoDB\Driver\Query(
3636
'limit' => 1,
3737
)
3838
);
39-
$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, $rp);
39+
$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, ['readPreference' => $rp]);
4040
$profileEntry = current($cursor->toArray());
4141

4242
if (! isset( $profileEntry->command )) {

tests/server/server-executeQuery-008.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ $dataBearingNodes = count(array_filter($manager->getServers(), function (MongoDB
2121

2222
$bulk = new \MongoDB\Driver\BulkWrite;
2323
$bulk->insert(['_id' => 1, 'x' => 1]);
24-
$primary->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($dataBearingNodes));
24+
$primary->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($dataBearingNodes)]);
2525

2626
$secondaryRp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::SECONDARY);
2727
$secondary = $manager->selectServer($secondaryRp);
2828

2929
/* Note: this is testing that the read preference (even a conflicting one) has
3030
* no effect when directly querying a server, since the secondaryOk flag is always
3131
* set for hinted queries. */
32-
$cursor = $secondary->executeQuery(NS, new MongoDB\Driver\Query(['x' => 1]), $primaryRp);
32+
$cursor = $secondary->executeQuery(NS, new MongoDB\Driver\Query(['x' => 1]), ['readPreference' => $primaryRp]);
3333

3434
var_dump($cursor->toArray());
3535

tests/server/server-executeQuery-010.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ $secondary = $manager->selectServer($secondaryRp);
2424

2525
echo "Testing primary:\n";
2626
$query = new MongoDB\Driver\Query(['x' => 3], ['projection' => ['y' => 1]]);
27-
$cursor = $manager->executeQuery(NS, $query, $primaryRp);
27+
$cursor = $primary->executeQuery(NS, $query, $primaryRp);
2828

2929
echo "is_primary: ", $cursor->getServer()->isPrimary() ? 'true' : 'false', "\n";
3030
echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "\n\n";
3131

3232
echo "Testing secondary:\n";
3333
$query = new MongoDB\Driver\Query(['x' => 3], ['projection' => ['y' => 1]]);
34-
$cursor = $manager->executeQuery(NS, $query, $secondaryRp);
34+
$cursor = $secondary->executeQuery(NS, $query, $secondaryRp);
3535

3636
echo "is_primary: ", $cursor->getServer()->isPrimary() ? 'true' : 'false', "\n";
3737
echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "\n\n";
@@ -40,10 +40,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
4040
<?php exit(0); ?>
4141
--EXPECTF--
4242
Testing primary:
43+
44+
Deprecated: MongoDB\Driver\Server::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4345
is_primary: true
4446
is_secondary: false
4547

4648
Testing secondary:
49+
50+
Deprecated: MongoDB\Driver\Server::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4751
is_primary: false
4852
is_secondary: true
4953

tests/standalone/bug0545.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ $page1->content = 'Lorem ipsum';
5757
$book->pages[] = $page1;
5858
$bulk = new MongoDB\Driver\BulkWrite;
5959
$bulk->insert($book);
60-
$result = $manager->executeBulkWrite(NS, $bulk, $wc);
60+
$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]);
6161
printf("Inserted %d document(s)\n", $result->getInsertedCount());
6262

6363
// Read
@@ -72,7 +72,7 @@ $page2->content = 'Dolor sit amet';
7272
$bookAfterInsert->pages[] = $page2;
7373
$bulk = new MongoDB\Driver\BulkWrite;
7474
$bulk->update(['title' => $bookAfterInsert->title], $bookAfterInsert);
75-
$result = $manager->executeBulkWrite(NS, $bulk, $wc);
75+
$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]);
7676
printf("Modified %d document(s)\n", $result->getModifiedCount());
7777

7878
// Read (again)

tests/standalone/manager-as-singleton.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Database {
3030
}
3131

3232
public function query($scheme, $query) {
33-
return $this->Database->executeQuery($scheme, $query, new ReadPreference(ReadPreference::PRIMARY));
33+
return $this->Database->executeQuery($scheme, $query, ['readPreference' => new ReadPreference(ReadPreference::PRIMARY)]);
3434
}
3535
}
3636

tests/standalone/write-error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $w = 2;
2020
$wtimeout = 1000;
2121
$writeConcern = new \MongoDB\Driver\WriteConcern($w, $wtimeout);
2222
echo throws(function() use($bulk, $writeConcern, $manager) {
23-
$result = $manager->executeBulkWrite(NS, $bulk, $writeConcern);
23+
$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $writeConcern]);
2424
}, "MongoDB\Driver\Exception\BulkWriteException"), "\n";
2525

2626
?>

tests/standalone/writeresult-isacknowledged-003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $manager = create_test_manager();
1212

1313
$bulk = new \MongoDB\Driver\BulkWrite;
1414
$bulk->insert(array('x' => 2));
15-
$result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
15+
$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(0)]);
1616

1717
printf("WriteResult::isAcknowledged(): %s\n", $result->isAcknowledged() ? 'true' : 'false');
1818
var_dump($result);

tests/writeConcernError/writeconcernerror-debug-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $bulk->insert(['x' => 1]);
1515

1616
try {
1717
/* We assume that the replica set does not have 12 nodes */
18-
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(12));
18+
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(12)]);
1919
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
2020
var_dump($e->getWriteResult()->getWriteConcernError());
2121
}

tests/writeConcernError/writeconcernerror-getcode-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $bulk->insert(['x' => 1]);
1515

1616
try {
1717
/* We assume that the replica set does not have 12 nodes */
18-
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(12));
18+
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(12)]);
1919
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
2020
var_dump($e->getWriteResult()->getWriteConcernError()->getCode());
2121
}

tests/writeConcernError/writeconcernerror-getmessage-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $bulk->insert(['x' => 1]);
1515

1616
try {
1717
/* We assume that the replica set does not have 12 nodes */
18-
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(12));
18+
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(12)]);
1919
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
2020
var_dump($e->getWriteResult()->getWriteConcernError()->getMessage());
2121
}

tests/writeResult/writeresult-debug-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $bulk->insert(['_id' => 3]);
2222

2323
try {
2424
/* We assume that the replica set does not have 30 nodes */
25-
$result = $manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(30));
25+
$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(30)]);
2626
} catch (MongoDB\Driver\Exception\BulkWriteException $e) {
2727
var_dump($e->getWriteResult());
2828
}

0 commit comments

Comments
 (0)