Skip to content

Commit 37e313b

Browse files
committed
Note why Bucket's codec option is not passed to CollectionWrapper
1 parent be623a4 commit 37e313b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/GridFS/Bucket.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ public function __construct(Manager $manager, string $databaseName, array $optio
186186
$this->typeMap = $options['typeMap'] ?? self::DEFAULT_TYPE_MAP;
187187
$this->writeConcern = $options['writeConcern'] ?? $this->manager->getWriteConcern();
188188

189+
/* The codec option is intentionally omitted when constructing the files
190+
* and chunks collections so as not to interfere with internal GridFS
191+
* operations. Any codec will be manually applied when querying the
192+
* files collection (i.e. find, findOne, and getFileDocumentForStream).
193+
*/
189194
$collectionOptions = array_intersect_key($options, ['readConcern' => 1, 'readPreference' => 1, 'typeMap' => 1, 'writeConcern' => 1]);
190195

191196
$this->collectionWrapper = new CollectionWrapper($manager, $databaseName, $options['bucketName'], $collectionOptions);

0 commit comments

Comments
 (0)