Commit df6df1c5 authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #533

parents 5e1ce36b 37168ad8
...@@ -9,7 +9,10 @@ description: | ...@@ -9,7 +9,10 @@ description: |
For replica sets, do not set ``autoIndexId`` to ``false``. 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 interface: phpmethod
operation: ~ operation: ~
optional: true optional: true
......
...@@ -53,6 +53,10 @@ class CreateCollection implements Executable ...@@ -53,6 +53,10 @@ class CreateCollection implements Executable
* of an index on the _id field. For replica sets, this option cannot be * of an index on the _id field. For replica sets, this option cannot be
* false. The default is true. * 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, * * capped (boolean): Specify true to create a capped collection. If set,
* the size option must also be specified. The default is false. * the size option must also be specified. The default is false.
* *
...@@ -170,6 +174,10 @@ class CreateCollection implements Executable ...@@ -170,6 +174,10 @@ class CreateCollection implements Executable
unset($options['writeConcern']); 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->databaseName = (string) $databaseName;
$this->collectionName = (string) $collectionName; $this->collectionName = (string) $collectionName;
$this->options = $options; $this->options = $options;
......
...@@ -82,4 +82,15 @@ class CreateCollectionTest extends TestCase ...@@ -82,4 +82,15 @@ class CreateCollectionTest extends TestCase
return $options; 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 ...@@ -52,6 +52,23 @@ abstract class TestCase extends BaseTestCase
return $this->wrapValuesForDataProvider($this->getInvalidDocumentValues()); 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) protected function assertSameDocument($expectedDocument, $actualDocument)
{ {
$this->assertEquals( $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