-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6159 from nicolas-cajelli/backport-fix-relation-c…
- Loading branch information
Showing
9 changed files
with
79 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
|
||
/** | ||
* @author Fabio B. Silva <[email protected]> | ||
* @author Guilherme Blanco <[email protected]> | ||
* @since 2.5 | ||
*/ | ||
abstract class AbstractCollectionPersister implements CachedCollectionPersister | ||
|
@@ -164,10 +165,18 @@ public function loadCollectionCache(PersistentCollection $collection, Collection | |
public function storeCollectionCache(CollectionCacheKey $key, $elements) | ||
{ | ||
/* @var $targetPersister CachedEntityPersister */ | ||
$associationMapping = $this->sourceEntity->associationMappings[$key->association]; | ||
$targetPersister = $this->uow->getEntityPersister($this->targetEntity->rootEntityName); | ||
$targetRegion = $targetPersister->getCacheRegion(); | ||
$targetHydrator = $targetPersister->getEntityHydrator(); | ||
$entry = $this->hydrator->buildCacheEntry($this->targetEntity, $key, $elements); | ||
|
||
// Only preserve ordering if association configured it | ||
if ( ! (isset($associationMapping['indexBy']) && $associationMapping['indexBy'])) { | ||
// Elements may be an array or a Collection | ||
$elements = array_values(is_array($elements) ? $elements : $elements->getValues()); | ||
} | ||
|
||
$entry = $this->hydrator->buildCacheEntry($this->targetEntity, $key, $elements); | ||
|
||
foreach ($entry->identifiers as $index => $entityKey) { | ||
if ($targetRegion->contains($entityKey)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
* Specific non-strict read/write cached entity persister | ||
* | ||
* @author Fabio B. Silva <[email protected]> | ||
* @author Guilherme Blanco <[email protected]> | ||
* @since 2.5 | ||
*/ | ||
class NonStrictReadWriteCachedEntityPersister extends AbstractEntityPersister | ||
|
@@ -78,13 +79,16 @@ public function afterTransactionRolledBack() | |
*/ | ||
public function delete($entity) | ||
{ | ||
$key = new EntityCacheKey($this->class->rootEntityName, $this->uow->getEntityIdentifier($entity)); | ||
$key = new EntityCacheKey($this->class->rootEntityName, $this->uow->getEntityIdentifier($entity)); | ||
$deleted = $this->persister->delete($entity); | ||
|
||
if ($this->persister->delete($entity)) { | ||
if ($deleted) { | ||
$this->region->evict($key); | ||
} | ||
|
||
$this->queuedCache['delete'][] = $key; | ||
|
||
return $deleted; | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
* Specific read-write entity persister | ||
* | ||
* @author Fabio B. Silva <[email protected]> | ||
* @author Guilherme Blanco <[email protected]> | ||
* @since 2.5 | ||
*/ | ||
class ReadWriteCachedEntityPersister extends AbstractEntityPersister | ||
|
@@ -100,21 +101,24 @@ public function afterTransactionRolledBack() | |
*/ | ||
public function delete($entity) | ||
{ | ||
$key = new EntityCacheKey($this->class->rootEntityName, $this->uow->getEntityIdentifier($entity)); | ||
$lock = $this->region->lock($key); | ||
$key = new EntityCacheKey($this->class->rootEntityName, $this->uow->getEntityIdentifier($entity)); | ||
$lock = $this->region->lock($key); | ||
$deleted = $this->persister->delete($entity); | ||
|
||
if ($this->persister->delete($entity)) { | ||
if ($deleted) { | ||
$this->region->evict($key); | ||
} | ||
|
||
if ($lock === null) { | ||
return; | ||
return $deleted; | ||
} | ||
|
||
$this->queuedCache['delete'][] = array( | ||
'lock' => $lock, | ||
'key' => $key | ||
); | ||
|
||
return $deleted; | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters