Skip to content

Commit 3c35cc9

Browse files
committed
Check before inheriting collection read concern in watch()
1 parent 67cad14 commit 3c35cc9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Collection.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,14 @@ public function watch(array $pipeline = [], array $options = [])
956956

957957
$server = $this->manager->selectServer($options['readPreference']);
958958

959-
if ( ! isset($options['readConcern'])) {
959+
/* Although change streams require a newer version of the server than
960+
* read concerns, perform the usual wire version check before inheriting
961+
* the collection's read concern. In the event that the server is too
962+
* old, this makes it more likely that users will encounter an error
963+
* related to change streams being unsupported instead of an
964+
* UnsupportedException regarding use of the "readConcern" option from
965+
* the Aggregate operation class. */
966+
if ( ! isset($options['readConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForReadConcern)) {
960967
$options['readConcern'] = $this->readConcern;
961968
}
962969

0 commit comments

Comments
 (0)