34
34
use function is_integer ;
35
35
use function is_object ;
36
36
use function is_string ;
37
- use function MongoDB \document_to_array ;
38
37
use function MongoDB \is_document ;
39
- use function trigger_error ;
40
-
41
- use const E_USER_DEPRECATED ;
42
38
43
39
/**
44
40
* Operation for the find command.
@@ -91,28 +87,15 @@ final class Find implements Executable, Explainable
91
87
* * maxAwaitTimeMS (integer): The maxium amount of time for the server to wait
92
88
* on new documents to satisfy a query, if cursorType is TAILABLE_AWAIT.
93
89
*
94
- * * maxScan (integer): Maximum number of documents or index keys to scan
95
- * when executing the query.
96
- *
97
- * This option has been deprecated since version 1.4.
98
- *
99
90
* * maxTimeMS (integer): The maximum amount of time to allow the query to
100
- * run. If "$maxTimeMS" also exists in the modifiers document, this
101
- * option will take precedence.
91
+ * run.
102
92
*
103
93
* * min (document): The inclusive upper bound for a specific index.
104
94
*
105
- * * modifiers (document): Meta operators that modify the output or
106
- * behavior of a query. Use of these operators is deprecated in favor of
107
- * named options.
108
- *
109
95
* * noCursorTimeout (boolean): The server normally times out idle cursors
110
96
* after an inactivity period (10 minutes) to prevent excess memory use.
111
97
* Set this option to prevent that.
112
98
*
113
- * * oplogReplay (boolean): Internal replication use only. The driver
114
- * should not set this. This option is deprecated as of MongoDB 4.4.
115
- *
116
99
* * projection (document): Limits the fields to return for the matching
117
100
* document.
118
101
*
@@ -131,14 +114,7 @@ final class Find implements Executable, Explainable
131
114
*
132
115
* * skip (integer): The number of documents to skip before returning.
133
116
*
134
- * * snapshot (boolean): Prevents the cursor from returning a document more
135
- * than once because of an intervening write operation.
136
- *
137
- * This options has been deprecated since version 1.4.
138
- *
139
- * * sort (document): The order in which to return matching documents. If
140
- * "$orderby" also exists in the modifiers document, this option will
141
- * take precedence.
117
+ * * sort (document): The order in which to return matching documents.
142
118
*
143
119
* * let (document): Map of parameter names and values. Values must be
144
120
* constant or closed expressions that do not reference document fields.
@@ -210,10 +186,6 @@ public function __construct(private string $databaseName, private string $collec
210
186
throw InvalidArgumentException::invalidType ('"maxAwaitTimeMS" option ' , $ this ->options ['maxAwaitTimeMS ' ], 'integer ' );
211
187
}
212
188
213
- if (isset ($ this ->options ['maxScan ' ]) && ! is_integer ($ this ->options ['maxScan ' ])) {
214
- throw InvalidArgumentException::invalidType ('"maxScan" option ' , $ this ->options ['maxScan ' ], 'integer ' );
215
- }
216
-
217
189
if (isset ($ this ->options ['maxTimeMS ' ]) && ! is_integer ($ this ->options ['maxTimeMS ' ])) {
218
190
throw InvalidArgumentException::invalidType ('"maxTimeMS" option ' , $ this ->options ['maxTimeMS ' ], 'integer ' );
219
191
}
@@ -222,18 +194,10 @@ public function __construct(private string $databaseName, private string $collec
222
194
throw InvalidArgumentException::expectedDocumentType ('"min" option ' , $ this ->options ['min ' ]);
223
195
}
224
196
225
- if (isset ($ this ->options ['modifiers ' ]) && ! is_document ($ this ->options ['modifiers ' ])) {
226
- throw InvalidArgumentException::expectedDocumentType ('"modifiers" option ' , $ this ->options ['modifiers ' ]);
227
- }
228
-
229
197
if (isset ($ this ->options ['noCursorTimeout ' ]) && ! is_bool ($ this ->options ['noCursorTimeout ' ])) {
230
198
throw InvalidArgumentException::invalidType ('"noCursorTimeout" option ' , $ this ->options ['noCursorTimeout ' ], 'boolean ' );
231
199
}
232
200
233
- if (isset ($ this ->options ['oplogReplay ' ]) && ! is_bool ($ this ->options ['oplogReplay ' ])) {
234
- throw InvalidArgumentException::invalidType ('"oplogReplay" option ' , $ this ->options ['oplogReplay ' ], 'boolean ' );
235
- }
236
-
237
201
if (isset ($ this ->options ['projection ' ]) && ! is_document ($ this ->options ['projection ' ])) {
238
202
throw InvalidArgumentException::expectedDocumentType ('"projection" option ' , $ this ->options ['projection ' ]);
239
203
}
@@ -262,10 +226,6 @@ public function __construct(private string $databaseName, private string $collec
262
226
throw InvalidArgumentException::invalidType ('"skip" option ' , $ this ->options ['skip ' ], 'integer ' );
263
227
}
264
228
265
- if (isset ($ this ->options ['snapshot ' ]) && ! is_bool ($ this ->options ['snapshot ' ])) {
266
- throw InvalidArgumentException::invalidType ('"snapshot" option ' , $ this ->options ['snapshot ' ], 'boolean ' );
267
- }
268
-
269
229
if (isset ($ this ->options ['sort ' ]) && ! is_document ($ this ->options ['sort ' ])) {
270
230
throw InvalidArgumentException::expectedDocumentType ('"sort" option ' , $ this ->options ['sort ' ]);
271
231
}
@@ -282,14 +242,6 @@ public function __construct(private string $databaseName, private string $collec
282
242
unset($ this ->options ['readConcern ' ]);
283
243
}
284
244
285
- if (isset ($ this ->options ['snapshot ' ])) {
286
- trigger_error ('The "snapshot" option is deprecated and will be removed in a future release ' , E_USER_DEPRECATED );
287
- }
288
-
289
- if (isset ($ this ->options ['maxScan ' ])) {
290
- trigger_error ('The "maxScan" option is deprecated and will be removed in a future release ' , E_USER_DEPRECATED );
291
- }
292
-
293
245
if (isset ($ this ->options ['codec ' ]) && isset ($ this ->options ['typeMap ' ])) {
294
246
throw InvalidArgumentException::cannotCombineCodecAndTypeMap ();
295
247
}
@@ -340,28 +292,6 @@ public function getCommandDocument(): array
340
292
// maxAwaitTimeMS is a Query level option so should not be considered here
341
293
unset($ options ['maxAwaitTimeMS ' ]);
342
294
343
- $ modifierFallback = [
344
- ['allowPartialResults ' , 'partial ' ],
345
- ['comment ' , '$comment ' ],
346
- ['hint ' , '$hint ' ],
347
- ['maxScan ' , '$maxScan ' ],
348
- ['max ' , '$max ' ],
349
- ['maxTimeMS ' , '$maxTimeMS ' ],
350
- ['min ' , '$min ' ],
351
- ['returnKey ' , '$returnKey ' ],
352
- ['showRecordId ' , '$showDiskLoc ' ],
353
- ['sort ' , '$orderby ' ],
354
- ['snapshot ' , '$snapshot ' ],
355
- ];
356
-
357
- foreach ($ modifierFallback as $ modifier ) {
358
- if (! isset ($ options [$ modifier [0 ]]) && isset ($ options ['modifiers ' ][$ modifier [1 ]])) {
359
- $ options [$ modifier [0 ]] = $ options ['modifiers ' ][$ modifier [1 ]];
360
- }
361
- }
362
-
363
- unset($ options ['modifiers ' ]);
364
-
365
295
return $ cmd + $ options ;
366
296
}
367
297
@@ -406,7 +336,7 @@ private function createQueryOptions(): array
406
336
}
407
337
}
408
338
409
- foreach (['allowDiskUse ' , 'allowPartialResults ' , 'batchSize ' , 'comment ' , 'hint ' , 'limit ' , 'maxAwaitTimeMS ' , 'maxScan ' , ' maxTimeMS ' , 'noCursorTimeout ' , 'oplogReplay ' , ' projection ' , 'readConcern ' , 'returnKey ' , 'showRecordId ' , 'skip ' , ' snapshot ' , 'sort ' ] as $ option ) {
339
+ foreach (['allowDiskUse ' , 'allowPartialResults ' , 'batchSize ' , 'comment ' , 'hint ' , 'limit ' , 'maxAwaitTimeMS ' , 'maxTimeMS ' , 'noCursorTimeout ' , 'projection ' , 'readConcern ' , 'returnKey ' , 'showRecordId ' , 'skip ' , 'sort ' ] as $ option ) {
410
340
if (isset ($ this ->options [$ option ])) {
411
341
$ options [$ option ] = $ this ->options [$ option ];
412
342
}
@@ -418,12 +348,6 @@ private function createQueryOptions(): array
418
348
}
419
349
}
420
350
421
- if (! empty ($ this ->options ['modifiers ' ])) {
422
- /** @psalm-var array|object */
423
- $ modifiers = $ this ->options ['modifiers ' ];
424
- $ options ['modifiers ' ] = is_object ($ modifiers ) ? document_to_array ($ modifiers ) : $ modifiers ;
425
- }
426
-
427
351
return $ options ;
428
352
}
429
353
}
0 commit comments