Skip to content

Commit 5ada249

Browse files
committed
PHPLIB-340: Deprecate maxScan query option
1 parent bbfbbd6 commit 5ada249

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

docs/includes/apiargs-MongoDBCollection-method-find-option.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ type: integer
148148
description: |
149149
Maximum number of documents or index keys to scan when executing the query.
150150
151+
.. deprecated:: 1.4
151152
.. versionadded:: 1.2
152153
interface: phpmethod
153154
operation: ~

src/Operation/Find.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class Find implements Executable, Explainable
8585
* * maxScan (integer): Maximum number of documents or index keys to scan
8686
* when executing the query.
8787
*
88+
* This option has been deprecated since version 1.4.
89+
*
8890
* * maxTimeMS (integer): The maximum amount of time to allow the query to
8991
* run. If "$maxTimeMS" also exists in the modifiers document, this
9092
* option will take precedence.
@@ -265,6 +267,10 @@ public function __construct($databaseName, $collectionName, $filter, array $opti
265267
trigger_error('The "snapshot" option is deprecated and will be removed in a future release', E_USER_DEPRECATED);
266268
}
267269

270+
if (isset($options['maxScan'])) {
271+
trigger_error('The "maxScan" option is deprecated and will be removed in a future release', E_USER_DEPRECATED);
272+
}
273+
268274
$this->databaseName = (string) $databaseName;
269275
$this->collectionName = (string) $collectionName;
270276
$this->filter = $filter;

src/Operation/FindOne.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class FindOne implements Executable, Explainable
5656
* * maxScan (integer): Maximum number of documents or index keys to scan
5757
* when executing the query.
5858
*
59+
* This option has been deprecated since version 1.4.
60+
*
5961
* * maxTimeMS (integer): The maximum amount of time to allow the query to
6062
* run. If "$maxTimeMS" also exists in the modifiers document, this
6163
* option will take precedence.

tests/Operation/FindTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ public function testSnapshotOptionIsDeprecated()
139139
});
140140
}
141141

142+
public function testMaxScanOptionIsDeprecated()
143+
{
144+
$this->assertDeprecated(function() {
145+
new Find($this->getDatabaseName(), $this->getCollectionName(), [], ['maxScan' => 1]);
146+
});
147+
}
148+
142149
private function getInvalidHintValues()
143150
{
144151
return [123, 3.14, true];

0 commit comments

Comments
 (0)