Commit df6df1c5 authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #533

parents 5e1ce36b 37168ad8
......@@ -9,7 +9,10 @@ description: |
For replica sets, do not set ``autoIndexId`` to ``false``.
.. deprecated:: 3.2. The ``autoIndexId`` option will be removed in MongoDB 3.4.
.. deprecated:: 1.4
This option has been deprecated since MongoDB 3.2. As of MongoDB 4.0, this
option cannot be ``false`` when creating a replicated collection (i.e. a
collection outside of the ``local`` database in any mongod mode).
interface: phpmethod
operation: ~
optional: true
......
......@@ -53,6 +53,10 @@ class CreateCollection implements Executable
* of an index on the _id field. For replica sets, this option cannot be
* false. The default is true.
*
* This option has been deprecated since MongoDB 3.2. As of MongoDB 4.0,
* this option cannot be false when creating a replicated collection
* (i.e. a collection outside of the local database in any mongod mode).
*
* * capped (boolean): Specify true to create a capped collection. If set,
* the size option must also be specified. The default is false.
*
......@@ -170,6 +174,10 @@ class CreateCollection implements Executable
unset($options['writeConcern']);
}
if (isset($options['autoIndexId'])) {
trigger_error('The "autoIndexId" option is deprecated and will be removed in a future release', E_USER_DEPRECATED);
}
$this->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName;
$this->options = $options;
......
......@@ -82,4 +82,15 @@ class CreateCollectionTest extends TestCase
return $options;
}
public function testAutoIndexIdOptionIsDeprecated()
{
$this->assertDeprecated(function() {
new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), ['autoIndexId' => true]);
});
$this->assertDeprecated(function() {
new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), ['autoIndexId' => false]);
});
}
}
......@@ -52,6 +52,23 @@ abstract class TestCase extends BaseTestCase
return $this->wrapValuesForDataProvider($this->getInvalidDocumentValues());
}
protected function assertDeprecated(callable $execution)
{
$errors = [];
set_error_handler(function($errno, $errstr) use (&$errors) {
$errors[] = $errstr;
}, E_USER_DEPRECATED);
try {
call_user_func($execution);
} finally {
restore_error_handler();
}
$this->assertCount(1, $errors);
}
protected function assertSameDocument($expectedDocument, $actualDocument)
{
$this->assertEquals(
......
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