Skip to content

Commit 8a8f3aa

Browse files
authored
Merge pull request #2012 from alcaeus/document-more-bc-breaks
Document more BC breaks
2 parents b03d693 + 1519012 commit 8a8f3aa

32 files changed

+1080
-333
lines changed

UPGRADE-1.3.md

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,71 @@
11
# UPGRADE FROM 1.2 TO 1.3
22

3+
## Aggregation builder
4+
5+
* The `debug`, `maxDistance` and `minDistance` methods in
6+
`Doctrine\ODM\MongoDB\Aggregation\Stage\Match` have been deprecated and will
7+
be removed in 2.0.
8+
* The `Doctrine\ODM\MongoDB\Aggregation\Expr::ensureArray` method will be
9+
private in 2.0.
10+
* The `Doctrine\ODM\MongoDB\Aggregation\Stage\Bucket::convertExpression` method
11+
will be private in 2.0.
12+
* The `Doctrine\ODM\MongoDB\Aggregation\Stage\BucketAuto::convertExpression`
13+
method will be private in 2.0.
14+
* The following methods in `Doctrine\ODM\MongoDB\Aggregation\Stage\GraphLookup`
15+
will be private in 2.0: `convertExpression`, `convertTargetFieldName`.
16+
* The `Doctrine\ODM\MongoDB\Aggregation\Stage\ReplaceRoot::convertExpression`
17+
method will be private in 2.0.
18+
* Calling `Doctrine\MongoDB\Aggregation\Stage\Match::geoWithinPolygon` with
19+
fewer than 3 arguments was deprecated and will cause errors in 2.0. A polygon
20+
must have at least 3 edges to be considered valid.
21+
22+
## Configuration
23+
24+
* The following methods in `Doctrine\ODM\MongoDB\Configuration` have been
25+
deprecated and will be removed in MongoDB ODM 2.0: `getLoggerCallable`,
26+
`getMongoCmd`, `getRetryConnect`, `getRetryQuery`, `setLoggerCallable`,
27+
`setMongoCmd`, `setRetryConnect`, `setRetryQuery`.
28+
* The `attributes` property will be private in MongoDB ODM 2.0 - if you are
29+
extending the configuration class you should no longer rely on it.
30+
* The `getDefaultRepositoryClassName` and `setDefaultRepositoryClassName`
31+
methods in `Doctrine\ODM\MongoDB\Configuration` have been deprecated in favor
32+
of `getDefaultDocumentRepositoryClassName` and
33+
`setDefaultDocumentRepositoryClassName`, respectively.
34+
35+
## Cursors
36+
37+
* The `Doctrine\ODM\MongoDB\Cursor`, `Doctrine\ODM\MongoDB\CommandCursor`, and
38+
`Doctrine\ODM\MongoDB\EagerCursor` classes have been deprecated and will be
39+
removed in 2.0. Their functionality will be covered by basic iterators. To
40+
typehint an ODM specific iterator, use the new
41+
`Doctrine\ODM\MongoDB\Iterator\Iterator` interface.
42+
43+
## Document Class Generation
44+
45+
Functionality regarding generation of document and repository classes was
46+
deprecated and will be dropped in 2.0. The following classes related to this
47+
functionality have been deprecated:
48+
* `Doctrine\ODM\MongoDB\Query\FieldExtractor`
49+
* `Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateDocumentsCommand`
50+
* `Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateRepositoriesCommand`
51+
* `Doctrine\ODM\MongoDB\Tools\DisconnectedClassMetadataFactory`
52+
* `Doctrine\ODM\MongoDB\Tools\DocumentGenerator`
53+
* `Doctrine\ODM\MongoDB\Tools\DocumentRepositoryGenerator`
54+
55+
## Document Manager
56+
57+
* The `Doctrine\ODM\MongoDB\DocumentManager::createDBRef` method was deprecated
58+
in favor of `createReference`. It will be dropped in 2.0.
59+
* The `Doctrine\ODM\MongoDB\DocumentManager::getConnection` method was
60+
deprecated and will be dropped in 2.0. The replacement, `getClient` will
61+
return a `MongoDB\Client` instance, but is not available in 1.x.
62+
63+
## Document Persister
64+
65+
* The `Doctrine\ODM\MongoDB\Persisters\DocumentPersister::prepareSortOrProjection`
66+
method was deprecated and will be dropped in 2.0. Use `prepareSort` or
67+
`prepareProjection` accordingly.
68+
369
## Events
470

571
### `onClassMetadataNotFound` event added
@@ -80,6 +146,16 @@ The `Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo` class has been deprecated
80146
in favor of `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` and will be dropped in
81147
2.0.
82148

149+
### Obsolete features deprecated
150+
151+
* The following methods in `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` were
152+
deprecated and will be removed in 2.0: `getDistance`, `getFile`,
153+
`getNamespace`, `isFile`, `mapFile`, `setDistance`, `setFile`,
154+
`setRequireIndexes`, `setSlaveOkay`.
155+
* The following properties `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` were
156+
deprecated and will be removed in 2.0: `distance`, `file`, `namespace`,
157+
`requireIndexes`, `slaveOkay`.
158+
83159
### Annotation mappings
84160

85161
* The `@NotSaved` annotation was deprecated and will be dropped in 2.0. Use the
@@ -91,6 +167,10 @@ in favor of `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` and will be dropped in
91167
* The `dropDups` option on the `@Index` annotation was deprecated and will be
92168
dropped without replacement in 2.0. This functionality is no longer
93169
available.
170+
* The `simple` option on the `@ReferenceOne` and `@ReferenceMany` annotations
171+
was deprecated and will be dropped in 2.0. Use `storeAs="id"` instead.
172+
* The `@Distance` annotation was deprecated and will be dropped in 2.0. GeoNear
173+
queries will no longer be supported, use the aggregation pipeline instead.
94174

95175
### XML mappings
96176

@@ -101,7 +181,7 @@ in favor of `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` and will be dropped in
101181
* The `drop-dups` attribute in the `index` element was deprecated and will be
102182
dropped without replacement in 2.0. This functionality is no longer
103183
available.
104-
184+
105185
### Full discriminator maps required
106186

107187
When using a discriminator map on a reference or embedded relationship,
@@ -147,6 +227,40 @@ set.
147227
* The following methods in `Doctrine\ODM\MongoDB\Query\Builder` were deprecated
148228
and will be dropped in 2.0: `mapReduce`, `map`, `reduce`, `finalize`, `out`,
149229
`mapReduceOptions`, `distanceMultiplier`, `geoNear`, `spherical`.
230+
* The following properties in `Doctrine\ODM\MongoDB\Query\Builder` will be
231+
private in MongoDB ODM 2.0: `collection`, `expr`, `query`.
232+
* The following properties in `Doctrine\ODM\MongoDB\Query\Expr` will be private
233+
in MongoDB ODM 2.0: `currentField`, `newObj`, `query`.
234+
* The `addManyToSet` and `pushAll` methods in
235+
`Doctrine\ODM\MongoDB\Query\Builder` and `Doctrine\ODM\MongoDB\Query\Expr`
236+
were deprecated and will be removed in 2.0. Use `each` in combination with
237+
`addToSet` and `push` respectively.
238+
* The following methods from `Doctrine\ODM\MongoDB\Query\Builder` and
239+
`Doctrine\ODM\MongoDB\Query\Expr` were deprecated and will be removed in 2.0:
240+
`maxDistance`, `minDistance`, `withinBox`, `withinCenter`,
241+
`withinCenterSphere`, `withinPolygon`.
242+
* The `Doctrine\MongoDB\Query\Query::count` method was deprecated and will be
243+
removed in MongoDB ODM 2.0. Iterators will not be countable in 2.0. Users
244+
should run separate count queries instead.
245+
* The `Doctrine\MongoDB\Query\Query::iterate` method was deprecated and will be
246+
removed in MongoDB ODM 2.0. Use `Doctrine\MongoDB\Query\Query::getIterator`
247+
instead.
248+
* The following properties in `Doctrine\ODM\MongoDB\Query\Query` will be
249+
private in MongoDB ODM 2.0: `iterator`, `options`, `query`.
250+
* The following constants in `Doctrine\ODM\MongoDB\Query\Query` will be removed
251+
in MongoDB ODM 2.0: `HINT_READ_PREFERENCE_TAGS`, `HINT_SLAVE_OKAY`,
252+
`TYPE_GEO_NEAR`.
253+
* The `Doctrine\ODM\MongoDB\Query\Query::prepareCursor` method will be removed
254+
in MongoDB ODM 2.0. You should wrap the returned cursor instead.
255+
* Calling `Doctrine\MongoDB\Query\Builder::geoWithinPolygon` and
256+
`Doctrine\MongoDB\Query\Expr::geoWithinPolygon` with fewer than 3 arguments
257+
was deprecated and will cause errors in 2.0. A polygon must have at least 3
258+
edges to be considered valid.
259+
260+
## Repositories
261+
* The `Doctrine\ODM\MongoDB\DocumentRepository` class was deprecated in favor
262+
of `Doctrine\ODM\MongoDB\Repository\DocumentRepository` and will be dropped
263+
in 2.0.
150264

151265
## Schema manager
152266

@@ -155,3 +269,17 @@ set.
155269
option instead.
156270
* The `indexOptions` argument in the `ensureSharding` and
157271
`ensureDocumentSharding` methods was deprecated and will be dropped in 2.0.
272+
273+
## Types
274+
275+
* The following classes in the `Doctrine\ODM\MongoDB\Types` namespace were
276+
deprecated and will be removed in 2.0: `FileType`, `IncrementType`.
277+
* The `FILE` and `INCREMENT` constants in `Doctrine\ODM\MongoDB\Types\Type`
278+
were deprecated and will be removed in 2.0.
279+
280+
## UnitOfWork
281+
282+
* The `isScheduledForDirtyCheck` and `scheduleForDirtyCheck` methods in
283+
`Doctrine\ODM\MongoDB\UnitOfWork` have been deprecated and will be dropped in
284+
2.0. Use `isScheduledForSynchronization` and `scheduleForSynchronization`
285+
instead.

lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function sortByCount($expression)
186186
public function sort($fieldName, $order = null)
187187
{
188188
$fields = is_array($fieldName) ? $fieldName : [$fieldName => $order];
189-
return parent::sort($this->getDocumentPersister()->prepareSortOrProjection($fields));
189+
return parent::sort($this->getDocumentPersister()->prepareSort($fields));
190190
}
191191

192192
/**

lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
use Doctrine\MongoDB\Aggregation\Expr as BaseExpr;
2424
use Doctrine\ODM\MongoDB\DocumentManager;
2525
use Doctrine\ODM\MongoDB\Types\Type;
26+
use const E_USER_DEPRECATED;
27+
use function sprintf;
28+
use function trigger_error;
2629

2730
/**
2831
* Fluent interface for building aggregation pipelines.
@@ -64,9 +67,15 @@ public function field($fieldName)
6467
/**
6568
* @param mixed|self $expression
6669
* @return mixed
70+
*
71+
* @internal This method will be private in MongoDB ODM 2.0.
6772
*/
6873
protected function ensureArray($expression)
6974
{
75+
if (self::class !== static::class) {
76+
@trigger_error(sprintf('The "%s" method will be private in MongoDB ODM 2.0. You should not rely on calling this method.', __METHOD__), E_USER_DEPRECATED);
77+
}
78+
7079
// Convert field names in expressions
7180
if (is_string($expression) && substr($expression, 0, 1) === '$') {
7281
return '$' . $this->getDocumentPersister()->prepareFieldName(substr($expression, 1));

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function __construct(Builder $builder, DocumentManager $documentManager,
4747

4848
protected function convertExpression($expression)
4949
{
50+
if (self::class !== static::class) {
51+
@trigger_error(sprintf('The "%s" method will be private in MongoDB ODM 2.0. You should not rely on calling this method.', __METHOD__), E_USER_DEPRECATED);
52+
}
53+
5054
if (is_array($expression)) {
5155
return array_map([$this, 'convertExpression'], $expression);
5256
} elseif (is_string($expression) && substr($expression, 0, 1) === '$') {

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function __construct(Builder $builder, DocumentManager $documentManager,
4747

4848
protected function convertExpression($expression)
4949
{
50+
if (self::class !== static::class) {
51+
@trigger_error(sprintf('The "%s" method will be private in MongoDB ODM 2.0. You should not rely on calling this method.', __METHOD__), E_USER_DEPRECATED);
52+
}
53+
5054
if (is_array($expression)) {
5155
return array_map([$this, 'convertExpression'], $expression);
5256
} elseif (is_string($expression) && substr($expression, 0, 1) === '$') {

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ private function fromReference($fieldName)
155155

156156
protected function convertExpression($expression)
157157
{
158+
if (self::class !== static::class) {
159+
@trigger_error(sprintf('The "%s" method will be private in MongoDB ODM 2.0. You should not rely on calling this method.', __METHOD__), E_USER_DEPRECATED);
160+
}
161+
158162
if (is_array($expression)) {
159163
return array_map([$this, 'convertExpression'], $expression);
160164
} elseif (is_string($expression) && substr($expression, 0, 1) === '$') {
@@ -166,6 +170,10 @@ protected function convertExpression($expression)
166170

167171
protected function convertTargetFieldName($fieldName)
168172
{
173+
if (self::class !== static::class) {
174+
@trigger_error(sprintf('The "%s" method will be private in MongoDB ODM 2.0. You should not rely on calling this method.', __METHOD__), E_USER_DEPRECATED);
175+
}
176+
169177
if (is_array($fieldName)) {
170178
return array_map([$this, 'convertTargetFieldName'], $fieldName);
171179
}

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Match.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
namespace Doctrine\ODM\MongoDB\Aggregation\Stage;
2121

2222
use Doctrine\MongoDB\Aggregation\Stage as BaseStage;
23+
use const E_USER_DEPRECATED;
24+
use function sprintf;
25+
use function func_get_args;
26+
use function func_num_args;
27+
use function trigger_error;
2328

2429
/**
2530
* Fluent interface for building aggregation pipelines.
@@ -47,4 +52,52 @@ public function includesReferenceTo($document)
4752

4853
return $this;
4954
}
55+
56+
/**
57+
* {@inheritdoc}
58+
*
59+
* @deprecated This method is deprecated and will be removed in MongoDB ODM 2.0.
60+
*/
61+
public function debug($name = null)
62+
{
63+
@trigger_error(sprintf('The "%s" method is deprecated and will be removed in MongoDB ODM 2.0.', __METHOD__), E_USER_DEPRECATED);
64+
65+
return parent::debug($name);
66+
}
67+
68+
/**
69+
* {@inheritdoc}
70+
*/
71+
public function geoWithinPolygon()
72+
{
73+
if (func_num_args() < 3) {
74+
@trigger_error(sprintf('Calling "%s" with fewer than 3 arguments was deprecated in MongoDB ODM 1.3 and will require at least 3 arguments in 2.0.', __METHOD__), E_USER_DEPRECATED);
75+
}
76+
77+
return parent::geoWithinPolygon(...func_get_args());
78+
}
79+
80+
/**
81+
* {@inheritdoc}
82+
*
83+
* @deprecated This method is deprecated and will be removed in MongoDB ODM 2.0.
84+
*/
85+
public function maxDistance($maxDistance)
86+
{
87+
@trigger_error(sprintf('The "%s" method is deprecated and will be removed in MongoDB ODM 2.0.', __METHOD__), E_USER_DEPRECATED);
88+
89+
return parent::maxDistance($maxDistance);
90+
}
91+
92+
/**
93+
* {@inheritdoc}
94+
*
95+
* @deprecated This method is deprecated and will be removed in MongoDB ODM 2.0.
96+
*/
97+
public function minDistance($minDistance)
98+
{
99+
@trigger_error(sprintf('The "%s" method is deprecated and will be removed in MongoDB ODM 2.0.', __METHOD__), E_USER_DEPRECATED);
100+
101+
return parent::minDistance($minDistance);
102+
}
50103
}

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function __construct(Builder $builder, DocumentManager $documentManager,
4747

4848
protected function convertExpression($expression)
4949
{
50+
if (self::class !== static::class) {
51+
@trigger_error(sprintf('The "%s" method will be private in MongoDB ODM 2.0. You should not rely on calling this method.', __METHOD__), E_USER_DEPRECATED);
52+
}
53+
5054
if (is_array($expression)) {
5155
return array_map([$this, 'convertExpression'], $expression);
5256
} elseif (is_string($expression) && substr($expression, 0, 1) === '$') {

lib/Doctrine/ODM/MongoDB/CommandCursor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*
3030
* @since 1.1
3131
* @author alcaeus <[email protected]>
32+
* @deprecated This class is deprecated and will be removed in 2.0. You should typehint against the {@see Iterator} interface instead.
3233
*/
3334
class CommandCursor implements Iterator
3435
{

0 commit comments

Comments
 (0)