1
0
mirror of synced 2025-02-13 10:49:25 +03:00

#6017 throwing an ORMInvalidArgumentException when clearing with non-string data. Also removing duplicate null checking

This commit is contained in:
Marco Pivetta 2016-11-27 18:11:27 +01:00
parent c97799f151
commit 754e1f5d42

View File

@ -2360,13 +2360,11 @@ class UnitOfWork implements PropertyChangedListener
* @param string|null $entityName if given, only entities of this type will get detached. * @param string|null $entityName if given, only entities of this type will get detached.
* *
* @return void * @return void
*
* @throws ORMInvalidArgumentException if an invalid entity name is given
*/ */
public function clear($entityName = null) public function clear($entityName = null)
{ {
if ($entityName !== null && !is_string($entityName)) {
throw ORMException::invalidEntityName($entityName);
}
if ($entityName === null) { if ($entityName === null) {
$this->identityMap = $this->identityMap =
$this->entityIdentifiers = $this->entityIdentifiers =
@ -2384,6 +2382,10 @@ class UnitOfWork implements PropertyChangedListener
$this->visitedCollections = $this->visitedCollections =
$this->orphanRemovals = array(); $this->orphanRemovals = array();
} else { } else {
if (! is_string($entityName)) {
throw ORMInvalidArgumentException::invalidEntityName($entityName);
}
$this->clearIdentityMapForEntityName($entityName); $this->clearIdentityMapForEntityName($entityName);
$this->clearEntityInsertionsForEntityName($entityName); $this->clearEntityInsertionsForEntityName($entityName);
} }