Skip to content

PHPC-2489: Deprecate passing WriteConcern and ReadPreference objects to execute methods #1770

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 3 commits into from
Jan 29, 2025
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
2 changes: 2 additions & 0 deletions src/phongo_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ zval* php_phongo_prep_legacy_option(zval* options, const char* key, bool* alloca
Z_ADDREF_P(options);
*allocated = true;

php_error_docref(NULL, E_DEPRECATED, "Passing the \"%s\" option directly is deprecated and will be removed in ext-mongodb 2.0", key);

return new_options;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/bulk/write-0002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $w = 1;
$wtimeout = 1000;
$writeConcern = new \MongoDB\Driver\WriteConcern($w, $wtimeout);
var_dump($insertBulk);
$result = $manager->executeBulkWrite(NS, $insertBulk, $writeConcern);
$result = $manager->executeBulkWrite(NS, $insertBulk, ['writeConcern' => $writeConcern]);
var_dump($insertBulk);

assert($result instanceof \MongoDB\Driver\WriteResult);
Expand Down
23 changes: 23 additions & 0 deletions tests/manager/manager-executeBulkWrite-015.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
MongoDB\Driver\Manager::executeBulkWrite() explicit WriteConcern argument is deprecated
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php skip_if_not_live(); ?>
<?php skip_if_not_clean(); ?>
--FILE--
<?php

require_once __DIR__ . "/../utils/basic.inc";

$manager = create_test_manager();

$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(['_id' => 1]);
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
Deprecated: MongoDB\Driver\Manager::executeBulkWrite(): Passing the "writeConcern" option directly is deprecated and will be removed in ext-mongodb 2.0%s
===DONE===
2 changes: 1 addition & 1 deletion tests/manager/manager-executeBulkWrite_error-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(array('_id' => 1, 'x' => 1));

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

Expand Down
4 changes: 4 additions & 0 deletions tests/manager/manager-executeCommand-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
<?php exit(0); ?>
--EXPECTF--
Testing primary:

Deprecated: MongoDB\Driver\Manager::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
is_primary: true
is_secondary: false

Testing secondary:

Deprecated: MongoDB\Driver\Manager::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
is_primary: false
is_secondary: true

Expand Down
4 changes: 4 additions & 0 deletions tests/manager/manager-executeQuery-004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
<?php exit(0); ?>
--EXPECTF--
Testing primary:

Deprecated: MongoDB\Driver\Manager::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
is_primary: true
is_secondary: false

Testing secondary:

Deprecated: MongoDB\Driver\Manager::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
is_primary: false
is_secondary: true

Expand Down
2 changes: 1 addition & 1 deletion tests/readPreference/bug0146-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $rps = [

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

Expand Down
2 changes: 1 addition & 1 deletion tests/replicaset/bug0155.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(array('example' => 'document'));

try {
$manager->executeBulkWrite(NS, $bulk, $wc);
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]);
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
var_dump($e->getWriteResult()->getWriteConcernError());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/replicaset/readconcern-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $wc = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY);
$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(['_id' => 1, 'x' => 1]);
$bulk->insert(['_id' => 2, 'x' => 2]);
$manager->executeBulkWrite(NS, $bulk, $wc);
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]);

$rc = new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::LOCAL);
$query = new MongoDB\Driver\Query(['x' => 2], ['readConcern' => $rc]);
Expand Down
2 changes: 1 addition & 1 deletion tests/replicaset/writeconcernerror-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $bulk->insert(array("my" => "value"));

$w = new MongoDB\Driver\WriteConcern(30, 100);
try {
$retval = $manager->executeBulkWrite(NS, $bulk, $w);
$retval = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $w]);
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
$server = $e->getWriteResult()->getServer();
$server->getPort();
Expand Down
2 changes: 1 addition & 1 deletion tests/replicaset/writeconcernerror-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $bulk->update(array("foo" => "bar"), array('$set' => array("foo" => "baz")), arr

$w = new MongoDB\Driver\WriteConcern(30);
try {
$retval = $manager->executeBulkWrite(NS, $bulk, $w);
$retval = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $w]);
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
printWriteResult($e->getWriteResult(), false);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/replicaset/writeresult-getserver-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var_dump($server == $server2);

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

var_dump($server == $server3);
var_dump($server->getPort(), $server3->getPort());
Expand Down
2 changes: 1 addition & 1 deletion tests/replicaset/writeresult-getserver-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var_dump($server == $server2);

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

var_dump($server == $server3);
var_dump($server->getPort(), $server3->getPort());
Expand Down
2 changes: 1 addition & 1 deletion tests/server/server-executeBulkWrite-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ foreach ($writeConcerns as $writeConcern) {
$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(array('wc' => $writeConcern));

$result = $primary->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($writeConcern));
$result = $primary->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($writeConcern)]);
var_dump($result->isAcknowledged());
var_dump($result->getInsertedCount());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/server/server-executeBulkWrite-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ foreach ($writeConcerns as $wc) {
$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(array('wc' => $wc));

$result = $server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern($wc));
$result = $server->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($wc)]);
var_dump($result->isAcknowledged());
var_dump($result->getInsertedCount());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/server/server-executeBulkWrite-004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ foreach ($writeConcerns as $wc) {
$bulk->insert(array('wc' => $wc));

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

Expand Down
2 changes: 1 addition & 1 deletion tests/server/server-executeBulkWrite-005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ foreach ($writeConcerns as $wc) {
$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(array('wc' => $wc));

$result = $server->executeBulkWrite('local.' . COLLECTION_NAME, $bulk, new MongoDB\Driver\WriteConcern($wc));
$result = $server->executeBulkWrite('local.' . COLLECTION_NAME, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern($wc)]);
var_dump($result->isAcknowledged());
var_dump($result->getInsertedCount());
}
Expand Down
24 changes: 24 additions & 0 deletions tests/server/server-executeBulkWrite-010.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
MongoDB\Driver\Server::executeBulkWrite() explicit WriteConcern argument is deprecated
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php skip_if_not_live(); ?>
<?php skip_if_not_clean(); ?>
--FILE--
<?php

require_once __DIR__ . "/../utils/basic.inc";

$manager = create_test_manager();
$server = $manager->selectServer();

$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(['_id' => 1]);
$server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
Deprecated: MongoDB\Driver\Server::executeBulkWrite(): Passing the "writeConcern" option directly is deprecated and will be removed in ext-mongodb 2.0%s
===DONE===
4 changes: 2 additions & 2 deletions tests/server/server-executeCommand-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $command = new MongoDB\Driver\Command([
'pipeline' => [ [ '$match' => [ 'x' => 1 ] ] ],
'cursor' => (object) [],
]);
$secondary->executeCommand(DATABASE_NAME, $command, $rp);
$secondary->executeCommand(DATABASE_NAME, $command, ['readPreference' => $rp]);

$query = new MongoDB\Driver\Query(
array(
Expand All @@ -37,7 +37,7 @@ $query = new MongoDB\Driver\Query(
'limit' => 1,
)
);
$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, $rp);
$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, ['readPreference' => $rp]);
$profileEntry = current($cursor->toArray());

var_dump($profileEntry->command);
Expand Down
2 changes: 1 addition & 1 deletion tests/server/server-executeCommand-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $secondary = $manager->selectServer($secondaryRp);
* no effect when directly querying a server, since the secondaryOk flag is always
* set for hinted commands. */
$primaryRp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::PRIMARY);
$cursor = $secondary->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(array('ping' => 1)), $primaryRp);
$cursor = $secondary->executeCommand(DATABASE_NAME, new MongoDB\Driver\Command(array('ping' => 1)), ['readPreference' => $primaryRp]);

var_dump($cursor->toArray());

Expand Down
4 changes: 4 additions & 0 deletions tests/server/server-executeCommand-005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
<?php exit(0); ?>
--EXPECTF--
Testing primary:

Deprecated: MongoDB\Driver\Server::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
is_primary: true
is_secondary: false

Testing secondary:

Deprecated: MongoDB\Driver\Server::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
is_primary: false
is_secondary: true

Expand Down
4 changes: 2 additions & 2 deletions tests/server/server-executeQuery-006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (empty($result->ok)) {
exit("Could not set profile level\n");
}

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

$query = new MongoDB\Driver\Query(
array(
Expand All @@ -36,7 +36,7 @@ $query = new MongoDB\Driver\Query(
'limit' => 1,
)
);
$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, $rp);
$cursor = $secondary->executeQuery(DATABASE_NAME . '.system.profile', $query, ['readPreference' => $rp]);
$profileEntry = current($cursor->toArray());

if (! isset( $profileEntry->command )) {
Expand Down
4 changes: 2 additions & 2 deletions tests/server/server-executeQuery-008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ $dataBearingNodes = count(array_filter($manager->getServers(), function (MongoDB

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

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

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

var_dump($cursor->toArray());

Expand Down
8 changes: 6 additions & 2 deletions tests/server/server-executeQuery-010.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ $secondary = $manager->selectServer($secondaryRp);

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

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

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

echo "is_primary: ", $cursor->getServer()->isPrimary() ? 'true' : 'false', "\n";
echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "\n\n";
Expand All @@ -40,10 +40,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
<?php exit(0); ?>
--EXPECTF--
Testing primary:

Deprecated: MongoDB\Driver\Server::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
is_primary: true
is_secondary: false

Testing secondary:

Deprecated: MongoDB\Driver\Server::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
is_primary: false
is_secondary: true

Expand Down
4 changes: 2 additions & 2 deletions tests/standalone/bug0545.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $page1->content = 'Lorem ipsum';
$book->pages[] = $page1;
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert($book);
$result = $manager->executeBulkWrite(NS, $bulk, $wc);
$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $wc]);
printf("Inserted %d document(s)\n", $result->getInsertedCount());

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

// Read (again)
Expand Down
2 changes: 1 addition & 1 deletion tests/standalone/manager-as-singleton.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Database {
}

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

Expand Down
2 changes: 1 addition & 1 deletion tests/standalone/write-error-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $w = 2;
$wtimeout = 1000;
$writeConcern = new \MongoDB\Driver\WriteConcern($w, $wtimeout);
echo throws(function() use($bulk, $writeConcern, $manager) {
$result = $manager->executeBulkWrite(NS, $bulk, $writeConcern);
$result = $manager->executeBulkWrite(NS, $bulk, ['writeConcern' => $writeConcern]);
}, "MongoDB\Driver\Exception\BulkWriteException"), "\n";

?>
Expand Down
2 changes: 1 addition & 1 deletion tests/standalone/writeresult-isacknowledged-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $manager = create_test_manager();

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

printf("WriteResult::isAcknowledged(): %s\n", $result->isAcknowledged() ? 'true' : 'false');
var_dump($result);
Expand Down
2 changes: 1 addition & 1 deletion tests/writeConcernError/writeconcernerror-debug-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $bulk->insert(['x' => 1]);

try {
/* We assume that the replica set does not have 12 nodes */
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(12));
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(12)]);
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
var_dump($e->getWriteResult()->getWriteConcernError());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $bulk->insert(['x' => 1]);

try {
/* We assume that the replica set does not have 12 nodes */
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(12));
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(12)]);
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
var_dump($e->getWriteResult()->getWriteConcernError()->getCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $bulk->insert(['x' => 1]);

try {
/* We assume that the replica set does not have 12 nodes */
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(12));
$manager->executeBulkWrite(NS, $bulk, ['writeConcern' => new MongoDB\Driver\WriteConcern(12)]);
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
var_dump($e->getWriteResult()->getWriteConcernError()->getMessage());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/writeResult/writeresult-debug-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $bulk->insert(['_id' => 3]);

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