Skip to content

Commit bbfbbd6

Browse files
committed
Merge pull request #531
2 parents 29f7cd0 + 491c3b7 commit bbfbbd6

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-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
@@ -221,6 +221,7 @@ description: |
221221
Prevents the cursor from returning a document more than once because of an
222222
intervening write operation.
223223
224+
.. deprecated:: 1.4
224225
.. versionadded:: 1.2
225226
interface: phpmethod
226227
operation: ~

src/Operation/Find.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ class Find implements Executable, Explainable
128128
* * snapshot (boolean): Prevents the cursor from returning a document more
129129
* than once because of an intervening write operation.
130130
*
131+
* This options has been deprecated since version 1.4.
132+
*
131133
* * sort (document): The order in which to return matching documents. If
132134
* "$orderby" also exists in the modifiers document, this option will
133135
* take precedence.
@@ -259,6 +261,10 @@ public function __construct($databaseName, $collectionName, $filter, array $opti
259261
unset($options['readConcern']);
260262
}
261263

264+
if (isset($options['snapshot'])) {
265+
trigger_error('The "snapshot" option is deprecated and will be removed in a future release', E_USER_DEPRECATED);
266+
}
267+
262268
$this->databaseName = (string) $databaseName;
263269
$this->collectionName = (string) $collectionName;
264270
$this->filter = $filter;

tests/Operation/FindTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ public function provideInvalidConstructorOptions()
128128
return $options;
129129
}
130130

131+
public function testSnapshotOptionIsDeprecated()
132+
{
133+
$this->assertDeprecated(function() {
134+
new Find($this->getDatabaseName(), $this->getCollectionName(), [], ['snapshot' => true]);
135+
});
136+
137+
$this->assertDeprecated(function() {
138+
new Find($this->getDatabaseName(), $this->getCollectionName(), [], ['snapshot' => false]);
139+
});
140+
}
141+
131142
private function getInvalidHintValues()
132143
{
133144
return [123, 3.14, true];

0 commit comments

Comments
 (0)