@@ -16,21 +16,25 @@ $manager = new MongoDB\Driver\Manager(STANDALONE);
16
16
$ command = new MongoDB \Driver \Command ([
17
17
'ping ' => true ,
18
18
]);
19
- $ manager ->executeCommand (
20
- DATABASE_NAME ,
21
- $ command ,
22
- [
23
- 'readPreference ' => new \MongoDB \Driver \ReadPreference (\MongoDB \Driver \ReadPreference::RP_SECONDARY ),
24
- 'readConcern ' => new \MongoDB \Driver \ReadConcern (\MongoDB \Driver \ReadConcern::LOCAL ),
25
- /* The ping command itself doesn't support writeConcern */
26
- // 'writeConcern' => new \MongoDB\Driver\WriteConcern(\MongoDB\Driver\WriteConcern::MAJORITY),
27
- ]
28
- );
19
+
20
+ try {
21
+ $ manager ->executeCommand (
22
+ DATABASE_NAME ,
23
+ $ command ,
24
+ [
25
+ 'readPreference ' => new \MongoDB \Driver \ReadPreference (\MongoDB \Driver \ReadPreference::RP_SECONDARY ),
26
+ 'readConcern ' => new \MongoDB \Driver \ReadConcern (\MongoDB \Driver \ReadConcern::LOCAL ),
27
+ 'writeConcern ' => new \MongoDB \Driver \WriteConcern (\MongoDB \Driver \WriteConcern::MAJORITY ),
28
+ ]
29
+ );
30
+ } catch ( Exception $ e ) {
31
+ // Ignore exception that ping doesn't support writeConcern
32
+ }
29
33
},
30
34
function (stdClass $ command ) {
31
35
echo "Read Preference: " , $ command ->{'$readPreference ' }->mode , "\n" ;
32
36
echo "Read Concern: " , $ command ->readConcern ->level , "\n" ;
33
- // echo "Write Concern: ", $command->writeConcern->w, "\n";
37
+ echo "Write Concern: " , $ command ->writeConcern ->w , "\n" ;
34
38
}
35
39
);
36
40
@@ -40,4 +44,5 @@ $manager = new MongoDB\Driver\Manager(STANDALONE);
40
44
--EXPECTF--
41
45
Read Preference: secondary
42
46
Read Concern: local
47
+ Write Concern: majority
43
48
===DONE===
0 commit comments