@@ -74,6 +74,9 @@ class Aggregate implements Executable
74
74
* This is not supported for server versions < 3.4 and will result in an
75
75
* exception at execution time if used.
76
76
*
77
+ * * comment (string): An arbitrary string to help trace the operation
78
+ * through the database profiler, currentOp, and logs.
79
+ *
77
80
* * hint (string|document): The index to use. Specify either the index
78
81
* name as a string or the index key pattern as a document. If specified,
79
82
* then the query system will only consider plans using the hinted index.
@@ -150,6 +153,10 @@ public function __construct($databaseName, $collectionName, array $pipeline, arr
150
153
throw InvalidArgumentException::invalidType ('"collation" option ' , $ options ['collation ' ], 'array or object ' );
151
154
}
152
155
156
+ if (isset ($ options ['comment ' ]) && ! is_string ($ options ['comment ' ])) {
157
+ throw InvalidArgumentException::invalidType ('"comment" option ' , $ options ['comment ' ], 'string ' );
158
+ }
159
+
153
160
if (isset ($ options ['hint ' ]) && ! is_string ($ options ['hint ' ]) && ! is_array ($ options ['hint ' ]) && ! is_object ($ options ['hint ' ])) {
154
161
throw InvalidArgumentException::invalidType ('"hint" option ' , $ options ['hint ' ], 'string or array or object ' );
155
162
}
@@ -276,6 +283,12 @@ private function createCommand(Server $server, $isCursorSupported)
276
283
$ cmd ['bypassDocumentValidation ' ] = $ this ->options ['bypassDocumentValidation ' ];
277
284
}
278
285
286
+ foreach (['comment ' , 'maxTimeMS ' ] as $ option ) {
287
+ if (isset ($ this ->options [$ option ])) {
288
+ $ cmd [$ option ] = $ this ->options [$ option ];
289
+ }
290
+ }
291
+
279
292
if (isset ($ this ->options ['collation ' ])) {
280
293
$ cmd ['collation ' ] = (object ) $ this ->options ['collation ' ];
281
294
}
@@ -284,10 +297,6 @@ private function createCommand(Server $server, $isCursorSupported)
284
297
$ cmd ['hint ' ] = is_array ($ this ->options ['hint ' ]) ? (object ) $ this ->options ['hint ' ] : $ this ->options ['hint ' ];
285
298
}
286
299
287
- if (isset ($ this ->options ['maxTimeMS ' ])) {
288
- $ cmd ['maxTimeMS ' ] = $ this ->options ['maxTimeMS ' ];
289
- }
290
-
291
300
if (isset ($ this ->options ['readConcern ' ])) {
292
301
$ cmd ['readConcern ' ] = \MongoDB \read_concern_as_document ($ this ->options ['readConcern ' ]);
293
302
}
0 commit comments