Skip to content

Commit f823cfd

Browse files
authored
Merge v1.17 into master (#1272)
2 parents 8c92163 + 62878a3 commit f823cfd

29 files changed

+174
-11
lines changed

docs/includes/extracts-bucket-option.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
ref: bucket-option-codec
2+
content: |
3+
The :doc:`codec </tutorial/codecs>` to use for encoding or decoding documents.
4+
This option is mutually exclusive with the ``typeMap`` option.
5+
6+
Defaults to the bucket's codec. Inheritance for a default ``codec`` option
7+
takes precedence over that of the ``typeMap`` option.
8+
---
19
ref: bucket-option-readConcern
210
source:
311
ref: common-option-readConcern

docs/includes/extracts-collection-option.yaml

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1+
ref: collection-option-codec
2+
content: |
3+
The :doc:`codec </tutorial/codecs>` to use for encoding or decoding documents.
4+
This option is mutually exclusive with the ``typeMap`` option.
5+
6+
Defaults to the collection's codec. Inheritance for a default ``codec`` option
7+
takes precedence over that of the ``typeMap`` option.
8+
---
19
ref: collection-option-collation
2-
source:
3-
ref: common-option-collation
4-
file: extracts-common-option.yaml
5-
post: |
10+
content: |
11+
:manual:`Collation </reference/collation>` allows users to specify
12+
language-specific rules for string comparison, such as rules for lettercase
13+
and accent marks. When specifying collation, the ``locale`` field is
14+
mandatory; all other collation fields are optional. For descriptions of the
15+
fields, see :manual:`Collation Document </reference/collation/#collation-document>`.
16+
617
If the collation is unspecified but the collection has a default collation,
718
the operation uses the collation specified for the collection. If no
819
collation is specified for the collection or for the operation, MongoDB uses

docs/includes/extracts-common-option.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
ref: common-option-codec
2+
content: |
3+
The :doc:`codec </tutorial/codecs>` to use for encoding or decoding documents.
4+
This option is mutually exclusive with the ``typeMap`` option.
5+
---
16
ref: common-option-collation
27
content: |
38
:manual:`Collation </reference/collation>` allows users to specify

docs/includes/extracts-watch-option.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ content: |
6161
6262
This is an option of the ``$changeStream`` pipeline stage.
6363
64-
.. versionadded: 1.13
64+
.. versionadded:: 1.13
6565
---
6666
ref: watch-option-maxAwaitTimeMS
6767
content: |
@@ -121,7 +121,7 @@ content: |
121121
122122
This is an option of the ``$changeStream`` pipeline stage.
123123
124-
.. versionadded: 1.5
124+
.. versionadded:: 1.5
125125
---
126126
ref: watch-option-startAtOperationTime
127127
content: |

docs/reference/class/MongoDBCollection.txt

-1
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,3 @@ Methods
144144
- :phpmethod:`MongoDB\Collection::updateSearchIndex()`
145145
- :phpmethod:`MongoDB\Collection::watch()`
146146
- :phpmethod:`MongoDB\Collection::withOptions()`
147-

docs/reference/method/MongoDBClient-selectCollection.txt

+7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ Parameters
4545
- Type
4646
- Description
4747

48+
* - codec
49+
- MongoDB\\Codec\\DocumentCodec
50+
- The default :doc:`codec </tutorial/codecs>` to use for collection
51+
operations.
52+
53+
.. versionadded:: 1.17
54+
4855
* - readConcern
4956
- :php:`MongoDB\Driver\ReadConcern <class.mongodb-driver-readconcern>`
5057
- The default read concern to use for collection operations. Defaults to

docs/reference/method/MongoDBClient-watch.txt

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Parameters
4848
- integer
4949
- .. include:: /includes/extracts/watch-option-batchSize.rst
5050

51+
* - codec
52+
- MongoDB\\Codec\\DocumentCodec
53+
- .. include:: /includes/extracts/common-option-codec.rst
54+
55+
.. versionadded:: 1.17
56+
5157
* - collation
5258
- array|object
5359
- .. include:: /includes/extracts/common-option-collation.rst

docs/reference/method/MongoDBCollection-aggregate.txt

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ Parameters
7070
This only applies when using the :ref:`$out <agg-out>` and
7171
:ref:`$out <agg-merge>` stages.
7272

73+
* - codec
74+
- MongoDB\\Codec\\DocumentCodec
75+
- .. include:: /includes/extracts/collection-option-codec.rst
76+
77+
.. versionadded:: 1.17
78+
7379
* - collation
7480
- array|object
7581
- .. include:: /includes/extracts/collection-option-collation.rst

docs/reference/method/MongoDBCollection-bulkWrite.txt

+9
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ Parameters
7070
- If ``true``, allows the write operation to circumvent document level
7171
validation. Defaults to ``false``.
7272

73+
* - codec
74+
- MongoDB\\Codec\\DocumentCodec
75+
- .. include:: /includes/extracts/collection-option-codec.rst
76+
77+
Bulk writes use the codec for ``insertOne`` and ``replaceOne``
78+
operations.
79+
80+
.. versionadded:: 1.17
81+
7382
* - comment
7483
- mixed
7584
- .. include:: /includes/extracts/common-option-comment.rst

docs/reference/method/MongoDBCollection-find.txt

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ Parameters
6161
Unlike the previous wire protocol version, a batchSize of ``1`` for the
6262
:dbcommand:`find` command does not close the cursor.
6363

64+
* - codec
65+
- MongoDB\\Codec\\DocumentCodec
66+
- .. include:: /includes/extracts/collection-option-codec.rst
67+
68+
.. versionadded:: 1.17
69+
6470
* - collation
6571
- array|object
6672
- .. include:: /includes/extracts/collection-option-collation.rst

docs/reference/method/MongoDBCollection-findOne.txt

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ Parameters
5252
the :program:`mongos` if some shards are unavailable instead of
5353
throwing an error.
5454

55+
* - codec
56+
- MongoDB\\Codec\\DocumentCodec
57+
- .. include:: /includes/extracts/collection-option-codec.rst
58+
59+
.. versionadded:: 1.17
60+
5561
* - collation
5662
- array|object
5763
- .. include:: /includes/extracts/collection-option-collation.rst

docs/reference/method/MongoDBCollection-findOneAndReplace.txt

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ Parameters
5050
- If ``true``, allows the write operation to circumvent document level
5151
validation. Defaults to ``false``.
5252

53+
* - codec
54+
- MongoDB\\Codec\\DocumentCodec
55+
- .. include:: /includes/extracts/collection-option-codec.rst
56+
57+
.. versionadded:: 1.17
58+
5359
* - collation
5460
- array|object
5561
- .. include:: /includes/extracts/collection-option-collation.rst

docs/reference/method/MongoDBCollection-insertMany.txt

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ Parameters
4646
- If ``true``, allows the write operation to circumvent document level
4747
validation. Defaults to ``false``.
4848

49+
* - codec
50+
- MongoDB\\Codec\\DocumentCodec
51+
- .. include:: /includes/extracts/collection-option-codec.rst
52+
53+
.. versionadded:: 1.17
54+
4955
* - comment
5056
- mixed
5157
- .. include:: /includes/extracts/common-option-comment.rst

docs/reference/method/MongoDBCollection-insertOne.txt

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ Parameters
4646
- If ``true``, allows the write operation to circumvent document level
4747
validation. Defaults to ``false``.
4848

49+
* - codec
50+
- MongoDB\\Codec\\DocumentCodec
51+
- .. include:: /includes/extracts/collection-option-codec.rst
52+
53+
.. versionadded:: 1.17
54+
4955
* - comment
5056
- mixed
5157
- .. include:: /includes/extracts/common-option-comment.rst

docs/reference/method/MongoDBCollection-listSearchIndexes.txt

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ Parameters
5252
returning a cursor or failure from ``aggregate`` without doing
5353
significant server-side work.
5454

55+
* - codec
56+
- MongoDB\\Codec\\DocumentCodec
57+
- .. include:: /includes/extracts/collection-option-codec.rst
58+
59+
.. versionadded:: 1.17
60+
5561
* - collation
5662
- array|object
5763
- .. include:: /includes/extracts/common-option-collation.rst

docs/reference/method/MongoDBCollection-replaceOne.txt

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ Parameters
5252
- If ``true``, allows the write operation to circumvent document level
5353
validation. Defaults to ``false``.
5454

55+
* - codec
56+
- MongoDB\\Codec\\DocumentCodec
57+
- .. include:: /includes/extracts/collection-option-codec.rst
58+
59+
.. versionadded:: 1.17
60+
5561
* - collation
5662
- array|object
5763
- .. include:: /includes/extracts/collection-option-collation.rst

docs/reference/method/MongoDBCollection-watch.txt

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Parameters
4848
- integer
4949
- .. include:: /includes/extracts/watch-option-batchSize.rst
5050

51+
* - codec
52+
- MongoDB\\Codec\\DocumentCodec
53+
- .. include:: /includes/extracts/collection-option-codec.rst
54+
55+
.. versionadded:: 1.17
56+
5157
* - collation
5258
- array|object
5359
- .. include:: /includes/extracts/common-option-collation.rst

docs/reference/method/MongoDBCollection-withOptions.txt

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ Parameters
3535
- Type
3636
- Description
3737

38+
* - codec
39+
- MongoDB\\Codec\\DocumentCodec
40+
- The default :doc:`codec </tutorial/codecs>` to use for collection
41+
operations. Defaults to the original collection's codec.
42+
43+
.. versionadded:: 1.17
44+
3845
* - readConcern
3946
- :php:`MongoDB\Driver\ReadConcern <class.mongodb-driver-readconcern>`
4047
- The default read concern to use for collection operations. Defaults to

docs/reference/method/MongoDBCollection__construct.txt

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ Definition
4949
- Type
5050
- Description
5151

52+
* - codec
53+
- MongoDB\\Codec\\DocumentCodec
54+
- The default :doc:`codec </tutorial/codecs>` to use for collection
55+
operations.
56+
57+
.. versionadded:: 1.17
58+
5259
* - readConcern
5360
- :php:`MongoDB\Driver\ReadConcern <class.mongodb-driver-readconcern>`
5461
- The default read concern to use for collection operations. Defaults to

docs/reference/method/MongoDBDatabase-aggregate.txt

+6
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ Parameters
7474
This only applies when using the :ref:`$out <agg-out>` and
7575
:ref:`$out <agg-merge>` stages.
7676

77+
* - codec
78+
- MongoDB\\Codec\\DocumentCodec
79+
- .. include:: /includes/extracts/common-option-codec.rst
80+
81+
.. versionadded:: 1.17
82+
7783
* - collation
7884
- array|object
7985
- .. include:: /includes/extracts/common-option-collation.rst

docs/reference/method/MongoDBDatabase-selectCollection.txt

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ Parameters
4141
- Type
4242
- Description
4343

44+
* - codec
45+
- MongoDB\\Codec\\DocumentCodec
46+
- The default :doc:`codec </tutorial/codecs>` to use for collection
47+
operations.
48+
49+
.. versionadded:: 1.17
50+
4451
* - readConcern
4552
- :php:`MongoDB\Driver\ReadConcern <class.mongodb-driver-readconcern>`
4653
- The default read concern to use for collection operations. Defaults to

docs/reference/method/MongoDBDatabase-selectGridFSBucket.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ Parameters
4444
- integer
4545
- The chunk size in bytes. Defaults to ``261120`` (i.e. 255 KiB).
4646

47+
* - codec
48+
- MongoDB\\Codec\\DocumentCodec
49+
- The default :doc:`codec </tutorial/codecs>` to use for bucket methods
50+
that return a file document (e.g. :phpmethod:`MongoDB\GridFS\Bucket::find()`).
51+
52+
.. versionadded:: 1.17
53+
4754
* - disableMD5
4855
- boolean
4956
- Whether to disable automatic MD5 generation when storing files.
5057

5158
Defaults to ``false``. Only ``true`` will be supported in 2.0.
5259

53-
.. versionadded: 1.4
60+
.. versionadded:: 1.4
5461

5562
* - readConcern
5663
- :php:`MongoDB\Driver\ReadConcern <class.mongodb-driver-readconcern>`

docs/reference/method/MongoDBDatabase-watch.txt

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Parameters
4848
- integer
4949
- .. include:: /includes/extracts/watch-option-batchSize.rst
5050

51+
* - codec
52+
- MongoDB\\Codec\\DocumentCodec
53+
- .. include:: /includes/extracts/common-option-codec.rst
54+
55+
.. versionadded:: 1.17
56+
5157
* - collation
5258
- array|object
5359
- .. include:: /includes/extracts/common-option-collation.rst

docs/reference/method/MongoDBGridFSBucket-find.txt

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ Parameters
6161
Unlike the previous wire protocol version, a batchSize of ``1`` for the
6262
:dbcommand:`find` command does not close the cursor.
6363

64+
* - codec
65+
- MongoDB\\Codec\\DocumentCodec
66+
- .. include:: /includes/extracts/bucket-option-codec.rst
67+
68+
.. versionadded:: 1.17
69+
6470
* - collation
6571
- array|object
6672
- .. include:: /includes/extracts/common-option-collation.rst

docs/reference/method/MongoDBGridFSBucket-findOne.txt

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ Parameters
5353
the :program:`mongos` if some shards are unavailable instead of
5454
throwing an error.
5555

56+
* - codec
57+
- MongoDB\\Codec\\DocumentCodec
58+
- .. include:: /includes/extracts/bucket-option-codec.rst
59+
60+
.. versionadded:: 1.17
61+
5662
* - collation
5763
- array|object
5864
- .. include:: /includes/extracts/common-option-collation.rst

docs/reference/method/MongoDBGridFSBucket-openUploadStream.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Parameters
5757

5858
Defaults to ``false``. Only ``true`` will be supported in 2.0.
5959

60-
.. versionadded: 1.4
60+
.. versionadded:: 1.4
6161

6262
* - metadata
6363
- array|object

docs/reference/method/MongoDBGridFSBucket-uploadFromStream.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Parameters
6161

6262
Defaults to ``false``. Only ``true`` will be supported in 2.0.
6363

64-
.. versionadded: 1.4
64+
.. versionadded:: 1.4
6565

6666
* - metadata
6767
- array|object

docs/reference/method/MongoDBGridFSBucket__construct.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,20 @@ Parameters
5555
- integer
5656
- The chunk size in bytes. Defaults to ``261120`` (i.e. 255 KiB).
5757

58+
* - codec
59+
- MongoDB\\Codec\\DocumentCodec
60+
- The default :doc:`codec </tutorial/codecs>` to use for bucket methods
61+
that return a file document (e.g. :phpmethod:`MongoDB\GridFS\Bucket::find()`).
62+
63+
.. versionadded:: 1.17
64+
5865
* - disableMD5
5966
- boolean
6067
- Whether to disable automatic MD5 generation when storing files.
6168

6269
Defaults to ``false``. Only ``true`` will be supported in 2.0.
6370

64-
.. versionadded: 1.4
71+
.. versionadded:: 1.4
6572

6673
* - readConcern
6774
- :php:`MongoDB\Driver\ReadConcern <class.mongodb-driver-readconcern>`

src/GridFS/Bucket.php

+5
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ public function __construct(Manager $manager, string $databaseName, array $optio
196196
$this->typeMap = $options['typeMap'] ?? self::DEFAULT_TYPE_MAP;
197197
$this->writeConcern = $options['writeConcern'] ?? $this->manager->getWriteConcern();
198198

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

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

0 commit comments

Comments
 (0)