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