@@ -75,15 +75,6 @@ class Collection
75
75
'root ' => BSONDocument::class,
76
76
];
77
77
78
- /** @var integer */
79
- private static $ wireVersionForFindAndModifyWriteConcern = 4 ;
80
-
81
- /** @var integer */
82
- private static $ wireVersionForReadConcern = 4 ;
83
-
84
- /** @var integer */
85
- private static $ wireVersionForWritableCommandWriteConcern = 5 ;
86
-
87
78
/** @var integer */
88
79
private static $ wireVersionForReadConcernWithWriteStage = 8 ;
89
80
@@ -236,7 +227,6 @@ public function aggregate(array $pipeline, array $options = [])
236
227
*/
237
228
if (
238
229
! isset ($ options ['readConcern ' ]) &&
239
- server_supports_feature ($ server , self ::$ wireVersionForReadConcern ) &&
240
230
! is_in_transaction ($ options ) &&
241
231
( ! $ hasWriteStage || server_supports_feature ($ server , self ::$ wireVersionForReadConcernWithWriteStage ))
242
232
) {
@@ -247,12 +237,7 @@ public function aggregate(array $pipeline, array $options = [])
247
237
$ options ['typeMap ' ] = $ this ->typeMap ;
248
238
}
249
239
250
- if (
251
- $ hasWriteStage &&
252
- ! isset ($ options ['writeConcern ' ]) &&
253
- server_supports_feature ($ server , self ::$ wireVersionForWritableCommandWriteConcern ) &&
254
- ! is_in_transaction ($ options )
255
- ) {
240
+ if ($ hasWriteStage && ! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
256
241
$ options ['writeConcern ' ] = $ this ->writeConcern ;
257
242
}
258
243
@@ -306,7 +291,7 @@ public function count($filter = [], array $options = [])
306
291
307
292
$ server = select_server ($ this ->manager , $ options );
308
293
309
- if (! isset ($ options ['readConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) && ! is_in_transaction ($ options )) {
294
+ if (! isset ($ options ['readConcern ' ]) && ! is_in_transaction ($ options )) {
310
295
$ options ['readConcern ' ] = $ this ->readConcern ;
311
296
}
312
297
@@ -335,7 +320,7 @@ public function countDocuments($filter = [], array $options = [])
335
320
336
321
$ server = select_server ($ this ->manager , $ options );
337
322
338
- if (! isset ($ options ['readConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) && ! is_in_transaction ($ options )) {
323
+ if (! isset ($ options ['readConcern ' ]) && ! is_in_transaction ($ options )) {
339
324
$ options ['readConcern ' ] = $ this ->readConcern ;
340
325
}
341
326
@@ -397,7 +382,7 @@ public function createIndexes(array $indexes, array $options = [])
397
382
{
398
383
$ server = select_server ($ this ->manager , $ options );
399
384
400
- if (! isset ($ options ['writeConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForWritableCommandWriteConcern ) && ! is_in_transaction ($ options )) {
385
+ if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
401
386
$ options ['writeConcern ' ] = $ this ->writeConcern ;
402
387
}
403
388
@@ -479,7 +464,7 @@ public function distinct($fieldName, $filter = [], array $options = [])
479
464
480
465
$ server = select_server ($ this ->manager , $ options );
481
466
482
- if (! isset ($ options ['readConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) && ! is_in_transaction ($ options )) {
467
+ if (! isset ($ options ['readConcern ' ]) && ! is_in_transaction ($ options )) {
483
468
$ options ['readConcern ' ] = $ this ->readConcern ;
484
469
}
485
470
@@ -506,7 +491,7 @@ public function drop(array $options = [])
506
491
507
492
$ server = select_server ($ this ->manager , $ options );
508
493
509
- if (! isset ($ options ['writeConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForWritableCommandWriteConcern ) && ! is_in_transaction ($ options )) {
494
+ if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
510
495
$ options ['writeConcern ' ] = $ this ->writeConcern ;
511
496
}
512
497
@@ -540,7 +525,7 @@ public function dropIndex($indexName, array $options = [])
540
525
541
526
$ server = select_server ($ this ->manager , $ options );
542
527
543
- if (! isset ($ options ['writeConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForWritableCommandWriteConcern ) && ! is_in_transaction ($ options )) {
528
+ if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
544
529
$ options ['writeConcern ' ] = $ this ->writeConcern ;
545
530
}
546
531
@@ -567,7 +552,7 @@ public function dropIndexes(array $options = [])
567
552
568
553
$ server = select_server ($ this ->manager , $ options );
569
554
570
- if (! isset ($ options ['writeConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForWritableCommandWriteConcern ) && ! is_in_transaction ($ options )) {
555
+ if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
571
556
$ options ['writeConcern ' ] = $ this ->writeConcern ;
572
557
}
573
558
@@ -595,7 +580,7 @@ public function estimatedDocumentCount(array $options = [])
595
580
596
581
$ server = select_server ($ this ->manager , $ options );
597
582
598
- if (! isset ($ options ['readConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) && ! is_in_transaction ($ options )) {
583
+ if (! isset ($ options ['readConcern ' ]) && ! is_in_transaction ($ options )) {
599
584
$ options ['readConcern ' ] = $ this ->readConcern ;
600
585
}
601
586
@@ -653,7 +638,7 @@ public function find($filter = [], array $options = [])
653
638
654
639
$ server = select_server ($ this ->manager , $ options );
655
640
656
- if (! isset ($ options ['readConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) && ! is_in_transaction ($ options )) {
641
+ if (! isset ($ options ['readConcern ' ]) && ! is_in_transaction ($ options )) {
657
642
$ options ['readConcern ' ] = $ this ->readConcern ;
658
643
}
659
644
@@ -686,7 +671,7 @@ public function findOne($filter = [], array $options = [])
686
671
687
672
$ server = select_server ($ this ->manager , $ options );
688
673
689
- if (! isset ($ options ['readConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) && ! is_in_transaction ($ options )) {
674
+ if (! isset ($ options ['readConcern ' ]) && ! is_in_transaction ($ options )) {
690
675
$ options ['readConcern ' ] = $ this ->readConcern ;
691
676
}
692
677
@@ -718,7 +703,7 @@ public function findOneAndDelete($filter, array $options = [])
718
703
{
719
704
$ server = select_server ($ this ->manager , $ options );
720
705
721
- if (! isset ($ options ['writeConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForFindAndModifyWriteConcern ) && ! is_in_transaction ($ options )) {
706
+ if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
722
707
$ options ['writeConcern ' ] = $ this ->writeConcern ;
723
708
}
724
709
@@ -755,7 +740,7 @@ public function findOneAndReplace($filter, $replacement, array $options = [])
755
740
{
756
741
$ server = select_server ($ this ->manager , $ options );
757
742
758
- if (! isset ($ options ['writeConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForFindAndModifyWriteConcern ) && ! is_in_transaction ($ options )) {
743
+ if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
759
744
$ options ['writeConcern ' ] = $ this ->writeConcern ;
760
745
}
761
746
@@ -792,7 +777,7 @@ public function findOneAndUpdate($filter, $update, array $options = [])
792
777
{
793
778
$ server = select_server ($ this ->manager , $ options );
794
779
795
- if (! isset ($ options ['writeConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForFindAndModifyWriteConcern ) && ! is_in_transaction ($ options )) {
780
+ if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
796
781
$ options ['writeConcern ' ] = $ this ->writeConcern ;
797
782
}
798
783
@@ -986,15 +971,15 @@ public function mapReduce(JavascriptInterface $map, JavascriptInterface $reduce,
986
971
*
987
972
* A read concern is also not compatible with transactions.
988
973
*/
989
- if (! isset ($ options ['readConcern ' ]) && ! ($ hasOutputCollection && $ this ->readConcern ->getLevel () === ReadConcern::MAJORITY ) && server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) && ! is_in_transaction ($ options )) {
974
+ if (! isset ($ options ['readConcern ' ]) && ! ($ hasOutputCollection && $ this ->readConcern ->getLevel () === ReadConcern::MAJORITY ) && ! is_in_transaction ($ options )) {
990
975
$ options ['readConcern ' ] = $ this ->readConcern ;
991
976
}
992
977
993
978
if (! isset ($ options ['typeMap ' ])) {
994
979
$ options ['typeMap ' ] = $ this ->typeMap ;
995
980
}
996
981
997
- if (! isset ($ options ['writeConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForWritableCommandWriteConcern ) && ! is_in_transaction ($ options )) {
982
+ if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
998
983
$ options ['writeConcern ' ] = $ this ->writeConcern ;
999
984
}
1000
985
@@ -1027,7 +1012,7 @@ public function rename(string $toCollectionName, ?string $toDatabaseName = null,
1027
1012
1028
1013
$ server = select_server ($ this ->manager , $ options );
1029
1014
1030
- if (! isset ($ options ['writeConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForWritableCommandWriteConcern ) && ! is_in_transaction ($ options )) {
1015
+ if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
1031
1016
$ options ['writeConcern ' ] = $ this ->writeConcern ;
1032
1017
}
1033
1018
@@ -1135,7 +1120,7 @@ public function watch(array $pipeline = [], array $options = [])
1135
1120
* related to change streams being unsupported instead of an
1136
1121
* UnsupportedException regarding use of the "readConcern" option from
1137
1122
* the Aggregate operation class. */
1138
- if (! isset ($ options ['readConcern ' ]) && server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) && ! is_in_transaction ($ options )) {
1123
+ if (! isset ($ options ['readConcern ' ]) && ! is_in_transaction ($ options )) {
1139
1124
$ options ['readConcern ' ] = $ this ->readConcern ;
1140
1125
}
1141
1126
0 commit comments