@@ -64,8 +64,8 @@ class Aggregate implements Executable
64
64
* * readConcern (MongoDB\Driver\ReadConcern): Read concern. Note that a
65
65
* "majority" read concern is not compatible with the $out stage.
66
66
*
67
- * For servers < 3.2, this option is ignored as read concern is not
68
- * available .
67
+ * This is not supported for server versions < 3.2 and will result in an
68
+ * exception at execution time if used .
69
69
*
70
70
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
71
71
*
@@ -182,7 +182,7 @@ public function __construct($databaseName, $collectionName, array $pipeline, arr
182
182
* @param Server $server
183
183
* @return Traversable
184
184
* @throws UnexpectedValueException if the command response was malformed
185
- * @throws UnsupportedException if collation or write concern is used and unsupported
185
+ * @throws UnsupportedException if collation, read concern, or write concern is used and unsupported
186
186
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
187
187
*/
188
188
public function execute (Server $ server )
@@ -191,6 +191,10 @@ public function execute(Server $server)
191
191
throw UnsupportedException::collationNotSupported ();
192
192
}
193
193
194
+ if (isset ($ this ->options ['readConcern ' ]) && ! \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern )) {
195
+ throw UnsupportedException::readConcernNotSupported ();
196
+ }
197
+
194
198
if (isset ($ this ->options ['writeConcern ' ]) && ! \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWriteConcern )) {
195
199
throw UnsupportedException::writeConcernNotSupported ();
196
200
}
@@ -254,7 +258,7 @@ private function createCommand(Server $server, $isCursorSupported)
254
258
$ cmd ['maxTimeMS ' ] = $ this ->options ['maxTimeMS ' ];
255
259
}
256
260
257
- if (isset ($ this ->options ['readConcern ' ]) && \ MongoDB \server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) ) {
261
+ if (isset ($ this ->options ['readConcern ' ])) {
258
262
$ cmd ['readConcern ' ] = \MongoDB \read_concern_as_document ($ this ->options ['readConcern ' ]);
259
263
}
260
264
0 commit comments