Skip to content

Commit

Permalink
Add BC layer for optimized collection operations
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Feb 4, 2019
1 parent 07b059f commit 02ecb89
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions UPGRADE-1.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ cause an exception in 2.0. It is possible to have multiple fields with the same
name in the database as long as all but one of them have the `notSaved` option
set.

## Persisters

* The `delete` and `update` methods in
`Doctrine\ODM\MongoDB\Persisters\CollectionPersister` are deprecated. Use
`deleteAll` and `updateAll` instead. The method signatures will be adapted
to match those of `deleteAll` and `updateAll` in 2.0.

## Queries

* The `eagerCursor` method in `Doctrine\ODM\MongoDB\Query\Builder` was
Expand Down
12 changes: 11 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Doctrine\ODM\MongoDB\UnitOfWork;
use Doctrine\ODM\MongoDB\Utility\CollectionHelper;
use UnexpectedValueException;
use const E_USER_DEPRECATED;
use function array_diff_key;
use function array_fill_keys;
use function array_flip;
Expand All @@ -40,8 +41,9 @@
use function get_class;
use function implode;
use function sort;
use function spl_object_hash;
use function sprintf;
use function strpos;
use function trigger_error;

/**
* The CollectionPersister is responsible for persisting collections of embedded
Expand Down Expand Up @@ -118,9 +120,13 @@ public function deleteAll($parent, array $collections, array $options)
*
* @param PersistentCollectionInterface $coll
* @param array $options
*
* @deprecated This method will be replaced with the deleteAll method
*/
public function delete(PersistentCollectionInterface $coll, array $options)
{
@trigger_error(sprintf('The "%s" method is deprecated and will be changed to the signature of deleteAll in 2.0.', __METHOD__), E_USER_DEPRECATED);

$mapping = $coll->getMapping();
if ($mapping['isInverseSide']) {
return; // ignore inverse side
Expand All @@ -139,9 +145,13 @@ public function delete(PersistentCollectionInterface $coll, array $options)
*
* @param PersistentCollectionInterface $coll
* @param array $options
*
* @deprecated This method will be replaced with the updateAll method
*/
public function update(PersistentCollectionInterface $coll, array $options)
{
@trigger_error(sprintf('The "%s" method is deprecated and will be changed to the signature of updateAll in 2.0.', __METHOD__), E_USER_DEPRECATED);

$mapping = $coll->getMapping();

if ($mapping['isInverseSide']) {
Expand Down

0 comments on commit 02ecb89

Please sign in to comment.