Skip to content

Commit b9f3591

Browse files
committed
Merge pull request #530
2 parents 5d2a8a4 + 0395858 commit b9f3591

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/Operation/FindAndModify.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public function execute(Server $server)
210210
throw UnsupportedException::writeConcernNotSupported();
211211
}
212212

213-
$cursor = $server->executeReadWriteCommand($this->databaseName, $this->createCommand($server), $this->createOptions());
213+
$cursor = $server->executeWriteCommand($this->databaseName, $this->createCommand($server), $this->createOptions());
214214
$result = current($cursor->toArray());
215215

216216
if ( ! isset($result->value)) {
@@ -280,7 +280,7 @@ private function createCommand(Server $server)
280280
/**
281281
* Create options for executing the command.
282282
*
283-
* @see http://php.net/manual/en/mongodb-driver-server.executereadwritecommand.php
283+
* @see http://php.net/manual/en/mongodb-driver-server.executewritecommand.php
284284
* @return array
285285
*/
286286
private function createOptions()

tests/Operation/FindAndModifyFunctionalTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,39 @@
33
namespace MongoDB\Tests\Operation;
44

55
use MongoDB\Driver\BulkWrite;
6+
use MongoDB\Driver\Manager;
7+
use MongoDB\Driver\ReadPreference;
68
use MongoDB\Model\BSONDocument;
79
use MongoDB\Operation\FindAndModify;
810
use MongoDB\Tests\CommandObserver;
911
use stdClass;
1012

1113
class FindAndModifyFunctionalTest extends FunctionalTestCase
1214
{
15+
/**
16+
* @see https://jira.mongodb.org/browse/PHPLIB-344
17+
*/
18+
public function testManagerReadConcernIsOmitted()
19+
{
20+
$manager = new Manager($this->getUri(), ['readConcernLevel' => 'majority']);
21+
$server = $manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
22+
23+
(new CommandObserver)->observe(
24+
function() use ($server) {
25+
$operation = new FindAndModify(
26+
$this->getDatabaseName(),
27+
$this->getCollectionName(),
28+
['remove' => true]
29+
);
30+
31+
$operation->execute($server);
32+
},
33+
function(stdClass $command) {
34+
$this->assertObjectNotHasAttribute('readConcern', $command);
35+
}
36+
);
37+
}
38+
1339
public function testDefaultWriteConcernIsOmitted()
1440
{
1541
(new CommandObserver)->observe(

0 commit comments

Comments
 (0)