1
0
mirror of synced 2025-01-31 12:32:59 +03:00

Merge branch 'hotfix/#1206-matching-should-not-modify-criteria'

Close #1206
This commit is contained in:
Marco Pivetta 2015-01-17 08:30:26 +01:00
commit 6ba5211310
2 changed files with 25 additions and 0 deletions

View File

@ -878,6 +878,7 @@ final class PersistentCollection implements Collection, Selectable
$expression = $criteria->getWhereExpression();
$expression = $expression ? $builder->andX($expression, $ownerExpression) : $ownerExpression;
$criteria = clone $criteria;
$criteria->where($expression);
$persister = $this->em->getUnitOfWork()->getEntityPersister($this->association['targetEntity']);

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Persistence\PersistentObject;
/**
@ -69,6 +70,29 @@ class PersistentCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertFalse($collection->isEmpty());
$this->assertFalse($collection->isInitialized());
}
/**
* @group #1206
* @group DDC-3430
*/
public function testMatchingDoesNotModifyTheGivenCriteria()
{
$collectionHolder = new PersistentCollectionHolder();
$this->_em->persist($collectionHolder);
$this->_em->flush();
$this->_em->clear();
$criteria = new Criteria();
$collectionHolder = $this->_em->find(__NAMESPACE__ . '\PersistentCollectionHolder', $collectionHolder->getId());
$collectionHolder->getCollection()->matching($criteria);
$this->assertEmpty($criteria->getWhereExpression());
$this->assertEmpty($criteria->getFirstResult());
$this->assertEmpty($criteria->getMaxResults());
$this->assertEmpty($criteria->getOrderings());
}
}
/**