Skip to content

Commit f9fd896

Browse files
committed
PHPLIB-1159: Remove CreateCollection autoIndexId option
1 parent ccc5ae2 commit f9fd896

File tree

3 files changed

+2
-30
lines changed

3 files changed

+2
-30
lines changed

src/Operation/CreateCollection.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ final class CreateCollection
4747
*
4848
* Supported options:
4949
*
50-
* * autoIndexId (boolean): Specify false to disable the automatic creation
51-
* of an index on the _id field. For replica sets, this option cannot be
52-
* false. The default is true.
53-
*
54-
* This option has been deprecated since MongoDB 3.2. As of MongoDB 4.0,
55-
* this option cannot be false when creating a replicated collection
56-
* (i.e. a collection outside of the local database in any mongod mode).
57-
*
5850
* * capped (boolean): Specify true to create a capped collection. If set,
5951
* the size option must also be specified. The default is false.
6052
*
@@ -123,10 +115,6 @@ final class CreateCollection
123115
*/
124116
public function __construct(private string $databaseName, private string $collectionName, private array $options = [])
125117
{
126-
if (isset($this->options['autoIndexId']) && ! is_bool($this->options['autoIndexId'])) {
127-
throw InvalidArgumentException::invalidType('"autoIndexId" option', $this->options['autoIndexId'], 'boolean');
128-
}
129-
130118
if (isset($this->options['capped']) && ! is_bool($this->options['capped'])) {
131119
throw InvalidArgumentException::invalidType('"capped" option', $this->options['capped'], 'boolean');
132120
}
@@ -207,10 +195,6 @@ public function __construct(private string $databaseName, private string $collec
207195
unset($this->options['writeConcern']);
208196
}
209197

210-
if (isset($this->options['autoIndexId'])) {
211-
trigger_error('The "autoIndexId" option is deprecated and will be removed in version 2.0', E_USER_DEPRECATED);
212-
}
213-
214198
if (isset($this->options['pipeline']) && ! is_pipeline($this->options['pipeline'], true /* allowEmpty */)) {
215199
throw new InvalidArgumentException('"pipeline" option is not a valid aggregation pipeline');
216200
}
@@ -233,7 +217,7 @@ private function createCommand(): Command
233217
{
234218
$cmd = ['create' => $this->collectionName];
235219

236-
foreach (['autoIndexId', 'capped', 'comment', 'expireAfterSeconds', 'max', 'maxTimeMS', 'pipeline', 'size', 'validationAction', 'validationLevel', 'viewOn'] as $option) {
220+
foreach (['capped', 'comment', 'expireAfterSeconds', 'max', 'maxTimeMS', 'pipeline', 'size', 'validationAction', 'validationLevel', 'viewOn'] as $option) {
237221
if (isset($this->options[$option])) {
238222
$cmd[$option] = $this->options[$option];
239223
}

tests/Operation/CreateCollectionTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public function testConstructorOptionTypeChecks(array $options): void
2525
public static function provideInvalidConstructorOptions()
2626
{
2727
return self::createOptionDataProvider([
28-
'autoIndexId' => self::getInvalidBooleanValues(),
2928
'capped' => self::getInvalidBooleanValues(),
3029
'changeStreamPreAndPostImages' => self::getInvalidDocumentValues(),
3130
'clusteredIndex' => self::getInvalidDocumentValues(),
@@ -47,15 +46,4 @@ public static function provideInvalidConstructorOptions()
4746
'writeConcern' => self::getInvalidWriteConcernValues(),
4847
]);
4948
}
50-
51-
public function testAutoIndexIdOptionIsDeprecated(): void
52-
{
53-
$this->assertDeprecated(function (): void {
54-
new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), ['autoIndexId' => true]);
55-
});
56-
57-
$this->assertDeprecated(function (): void {
58-
new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), ['autoIndexId' => false]);
59-
});
60-
}
6149
}

tests/UnifiedSpecTests/Util.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ final class Util
7575
Database::class => [
7676
'aggregate' => ['pipeline', 'session', 'allowDiskUse', 'batchSize', 'bypassDocumentValidation', 'collation', 'comment', 'explain', 'hint', 'let', 'maxAwaitTimeMS', 'maxTimeMS'],
7777
'createChangeStream' => ['pipeline', 'session', 'fullDocument', 'resumeAfter', 'startAfter', 'startAtOperationTime', 'batchSize', 'collation', 'maxAwaitTimeMS', 'showExpandedEvents'],
78-
'createCollection' => ['collection', 'session', 'autoIndexId', 'capped', 'changeStreamPreAndPostImages', 'clusteredIndex', 'collation', 'expireAfterSeconds', 'indexOptionDefaults', 'max', 'maxTimeMS', 'pipeline', 'size', 'storageEngine', 'timeseries', 'validationAction', 'validationLevel', 'validator', 'viewOn'],
78+
'createCollection' => ['collection', 'session', 'capped', 'changeStreamPreAndPostImages', 'clusteredIndex', 'collation', 'expireAfterSeconds', 'indexOptionDefaults', 'max', 'maxTimeMS', 'pipeline', 'size', 'storageEngine', 'timeseries', 'validationAction', 'validationLevel', 'validator', 'viewOn'],
7979
'dropCollection' => ['collection', 'session'],
8080
'listCollectionNames' => ['authorizedCollections', 'filter', 'maxTimeMS', 'session'],
8181
'listCollections' => ['authorizedCollections', 'filter', 'maxTimeMS', 'session'],

0 commit comments

Comments
 (0)