@@ -85,8 +85,6 @@ class Collection
85
85
'root ' => BSONDocument::class,
86
86
];
87
87
88
- private const WIRE_VERSION_FOR_READ_CONCERN_WITH_WRITE_STAGE = 8 ;
89
-
90
88
/** @psalm-var Encoder<array|stdClass|Document|PackedArray, mixed> */
91
89
private readonly Encoder $ builderEncoder ;
92
90
@@ -227,24 +225,17 @@ public function aggregate(array|Pipeline $pipeline, array $options = []): Cursor
227
225
$ hasWriteStage = is_last_pipeline_operator_write ($ pipeline );
228
226
229
227
$ options = $ this ->inheritReadPreference ($ options );
230
-
231
- $ server = $ hasWriteStage
232
- ? select_server_for_aggregate_write_stage ($ this ->manager , $ options )
233
- : select_server ($ this ->manager , $ options );
234
-
235
- /* MongoDB 4.2 and later supports a read concern when an $out stage is
236
- * being used, but earlier versions do not.
237
- */
238
- if (! $ hasWriteStage || server_supports_feature ($ server , self ::WIRE_VERSION_FOR_READ_CONCERN_WITH_WRITE_STAGE )) {
239
- $ options = $ this ->inheritReadConcern ($ options );
240
- }
241
-
228
+ $ options = $ this ->inheritReadConcern ($ options );
242
229
$ options = $ this ->inheritCodecOrTypeMap ($ options );
243
230
244
231
if ($ hasWriteStage ) {
245
232
$ options = $ this ->inheritWriteOptions ($ options );
246
233
}
247
234
235
+ $ server = $ hasWriteStage
236
+ ? select_server_for_aggregate_write_stage ($ this ->manager , $ options )
237
+ : select_server ($ this ->manager , $ options );
238
+
248
239
$ operation = new Aggregate ($ this ->databaseName , $ this ->collectionName , $ pipeline , $ options );
249
240
250
241
return $ operation ->execute ($ server );
0 commit comments