@@ -64,8 +64,8 @@ class Aggregate implements Executable
6464 * * readConcern (MongoDB\Driver\ReadConcern): Read concern. Note that a
6565 * "majority" read concern is not compatible with the $out stage.
6666 *
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 .
6969 *
7070 * * readPreference (MongoDB\Driver\ReadPreference): Read preference.
7171 *
@@ -182,7 +182,7 @@ public function __construct($databaseName, $collectionName, array $pipeline, arr
182182 * @param Server $server
183183 * @return Traversable
184184 * @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
186186 * @throws DriverRuntimeException for other driver errors (e.g. connection errors)
187187 */
188188 public function execute (Server $ server )
@@ -191,6 +191,10 @@ public function execute(Server $server)
191191 throw UnsupportedException::collationNotSupported ();
192192 }
193193
194+ if (isset ($ this ->options ['readConcern ' ]) && ! \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForReadConcern )) {
195+ throw UnsupportedException::readConcernNotSupported ();
196+ }
197+
194198 if (isset ($ this ->options ['writeConcern ' ]) && ! \MongoDB \server_supports_feature ($ server , self ::$ wireVersionForWriteConcern )) {
195199 throw UnsupportedException::writeConcernNotSupported ();
196200 }
@@ -254,7 +258,7 @@ private function createCommand(Server $server, $isCursorSupported)
254258 $ cmd ['maxTimeMS ' ] = $ this ->options ['maxTimeMS ' ];
255259 }
256260
257- if (isset ($ this ->options ['readConcern ' ]) && \ MongoDB \server_supports_feature ( $ server , self :: $ wireVersionForReadConcern ) ) {
261+ if (isset ($ this ->options ['readConcern ' ])) {
258262 $ cmd ['readConcern ' ] = \MongoDB \read_concern_as_document ($ this ->options ['readConcern ' ]);
259263 }
260264
0 commit comments