Skip to content

Commit

Permalink
bug #9516 [AclProvider] Fix incorrect behavior when partial results r…
Browse files Browse the repository at this point in the history
…eturned from cache (superdav42)

This PR was merged into the 2.2 branch.

Discussion
----------

[AclProvider] Fix incorrect behavior when partial results returned from cache

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #9515
| License       | MIT
| Doc PR        | none

[AclProvider] Fix incorrect behavior when partial results returned from cache

findAcls wasn't throwing the NotAllAclsFoundException with the partial result when some acls were retrieved from the cache. This will fix that behavior. Ideally we would update it to cache items that were not found so it wouldn't have to query the db every time for non existent items, but I'm not sure if that is possible.
I'm not sure if the ACL cache is being used very much, I didn't find any docs about it but it seems to work except for this issue. It might be more appropriate to merge the fix in master if no one is relying on it to work in 2.2.

Commits
-------

edae59c [AclProvider] Fix incorrect behaviour when partial results returned from cache
  • Loading branch information
fabpot committed Nov 22, 2013
2 parents 5e034fa + edae59c commit be0a605
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Symfony/Component/Security/Acl/Dbal/AclProvider.php
Expand Up @@ -165,8 +165,17 @@ public function findAcls(array $oids, array $sids = array())

// Is it time to load the current batch?
if ((self::MAX_BATCH_SIZE === count($currentBatch) || ($i + 1) === $c) && count($currentBatch) > 0) {
$loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup);

try {
$loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup);
} catch (AclNotFoundException $aclNotFoundexception) {
if ($result->count()) {
$partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
$partialResultException->setPartialResult($result);
throw $partialResultException;
} else {
throw $aclNotFoundexception;
}
}
foreach ($loadedBatch as $loadedOid) {
$loadedAcl = $loadedBatch->offsetGet($loadedOid);

Expand Down

0 comments on commit be0a605

Please sign in to comment.