From ecf25d2dc36058d4bd097285740c3c9a4a87df47 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Fri, 11 Jan 2019 08:00:36 +0100 Subject: [PATCH] Deprecate dropDups option on indexes (#1910) --- UPGRADE-1.3.md | 6 ++++++ docs/en/reference/indexes.rst | 3 ++- doctrine-mongo-mapping.xsd | 1 + .../ODM/MongoDB/Mapping/Annotations/AbstractIndex.php | 1 + lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php | 4 ++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/UPGRADE-1.3.md b/UPGRADE-1.3.md index 0188a73f50..38451af0da 100644 --- a/UPGRADE-1.3.md +++ b/UPGRADE-1.3.md @@ -50,6 +50,9 @@ in favor of `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` and will be dropped in * Using more than one class-level document annotation (e.g. `@Document`, `@MappedSuperclass`) is deprecated and will throw an exception in 2.0. Classes should only be annotated with a single document annotation. + * The `dropDups` option on the `@Index` annotation was deprecated and will be + dropped without replacement in 2.0. This functionality is no longer + available. ### XML mappings @@ -57,6 +60,9 @@ in favor of `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` and will be dropped in will be dropped in 2.0. Use `write-concern` instead. * The `fieldName` attribute in field mappings has been deprecated and will be dropped in 2.0. Use `field-name` instead. + * The `drop-dups` attribute in the `index` element was deprecated and will be + dropped without replacement in 2.0. This functionality is no longer + available. ### Full discriminator maps required diff --git a/docs/en/reference/indexes.rst b/docs/en/reference/indexes.rst index 52534f310c..569932c0eb 100644 --- a/docs/en/reference/indexes.rst +++ b/docs/en/reference/indexes.rst @@ -49,7 +49,8 @@ You can customize the index with some additional options: too long. - **dropDups** - If a unique index is being created and duplicate - values exist, drop all but one duplicate value. + values exist, drop all but one duplicate value. This option is deprecated and + will be dropped without replacement in 2.0. - **background** - Create indexes in the background while other operations are taking place. By default, index creation happens diff --git a/doctrine-mongo-mapping.xsd b/doctrine-mongo-mapping.xsd index f6d476ffc2..20564a547f 100644 --- a/doctrine-mongo-mapping.xsd +++ b/doctrine-mongo-mapping.xsd @@ -377,6 +377,7 @@ + diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractIndex.php b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractIndex.php index 4155be06b6..089cdab8dc 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractIndex.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractIndex.php @@ -25,6 +25,7 @@ abstract class AbstractIndex extends Annotation { public $keys = array(); public $name; + /** @deprecated */ public $dropDups; public $background; public $safe; diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php index 23589737f7..b1e7229f2d 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php @@ -889,6 +889,10 @@ public function setSlaveOkay($slaveOkay) */ public function addIndex($keys, array $options = array()) { + if (isset($options['dropDups'])) { + @trigger_error(sprintf('Ths "dropDups" option on indexes is deprecated and will be dropped in 2.0. Remove the "dropDups" options in class "%s".', $this->getName()), E_USER_DEPRECATED) + } + $this->indexes[] = array( 'keys' => array_map(function($value) { if ($value == 1 || $value == -1) {