Commit 491c3b7f authored by Katherine Walker's avatar Katherine Walker

PHPLIB-339: Deprecate snapshot option

parent 29f7cd0b
......@@ -221,6 +221,7 @@ description: |
Prevents the cursor from returning a document more than once because of an
intervening write operation.
.. deprecated:: 1.4
.. versionadded:: 1.2
interface: phpmethod
operation: ~
......
......@@ -128,6 +128,8 @@ class Find implements Executable, Explainable
* * snapshot (boolean): Prevents the cursor from returning a document more
* than once because of an intervening write operation.
*
* This options has been deprecated since version 1.4.
*
* * sort (document): The order in which to return matching documents. If
* "$orderby" also exists in the modifiers document, this option will
* take precedence.
......@@ -259,6 +261,10 @@ class Find implements Executable, Explainable
unset($options['readConcern']);
}
if (isset($options['snapshot'])) {
trigger_error('The "snapshot" option is deprecated and will be removed in a future release', E_USER_DEPRECATED);
}
$this->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->filter = $filter;
......
......@@ -128,6 +128,17 @@ class FindTest extends TestCase
return $options;
}
public function testSnapshotOptionIsDeprecated()
{
$this->assertDeprecated(function() {
new Find($this->getDatabaseName(), $this->getCollectionName(), [], ['snapshot' => true]);
});
$this->assertDeprecated(function() {
new Find($this->getDatabaseName(), $this->getCollectionName(), [], ['snapshot' => false]);
});
}
private function getInvalidHintValues()
{
return [123, 3.14, true];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment