From a77da9ba2e1099c184c06a10367c6154b4c30fcb Mon Sep 17 00:00:00 2001 From: Sergey Kolodyazhnyy Date: Wed, 4 Dec 2013 15:28:32 +0100 Subject: [PATCH 1/3] Fix Exception messages for ObjectIdentity ObjectIdentityInterface doesn't require implementing __toString method, so we need to make sure that object can be converted to string. --- src/Symfony/Component/Security/Acl/Dbal/AclProvider.php | 3 ++- src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php index b4791faf740a9..d1ec778a5486f 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php @@ -194,7 +194,8 @@ public function findAcls(array $oids, array $sids = array()) foreach ($oids as $oid) { if (!$result->contains($oid)) { if (1 === count($oids)) { - throw new AclNotFoundException(sprintf('No ACL found for %s.', $oid)); + $objectName = method_exists($oid, '__toString') ? $oid : get_class($oid); + throw new AclNotFoundException(sprintf('No ACL found for %s.', $objectName)); } $partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.'); diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php index e857c687c3c57..37515ed5a50c3 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php @@ -51,7 +51,8 @@ public function __construct(Connection $connection, PermissionGrantingStrategyIn public function createAcl(ObjectIdentityInterface $oid) { if (false !== $this->retrieveObjectIdentityPrimaryKey($oid)) { - throw new AclAlreadyExistsException(sprintf('%s is already associated with an ACL.', $oid)); + $objectName = method_exists($oid, '__toString') ? $oid : get_class($oid); + throw new AclAlreadyExistsException(sprintf('%s is already associated with an ACL.', $objectName)); } $this->connection->beginTransaction(); From eeac3f1aca72d27a599b1de2d552310cf4cf579f Mon Sep 17 00:00:00 2001 From: Sergey Kolodyazhnyy Date: Wed, 4 Dec 2013 15:29:18 +0100 Subject: [PATCH 2/3] Few SQL fixes for Oracle Database Oracle Database gives an error if you use 'AS' in FROM or JOIN instructions, it use uppercase for result array and it require strict type match in conditions --- .../Security/Acl/Dbal/AclProvider.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php index d1ec778a5486f..26d7da5c0ed69 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php @@ -284,7 +284,8 @@ protected function getAncestorLookupSql(array $batch) if (1 === count($types)) { $ids = array(); for ($i = 0; $i < $count; $i++) { - $ids[] = $this->connection->quote($batch[$i]->getIdentifier()); + $identifier = (string) $batch[$i]->getIdentifier(); + $ids[] = $this->connection->quote($identifier); } $sql .= sprintf( @@ -326,17 +327,17 @@ protected function getFindChildrenSql(ObjectIdentityInterface $oid, $directChild $query = <<options['oid_table_name']} as o - INNER JOIN {$this->options['class_table_name']} as c ON c.id = o.class_id - INNER JOIN {$this->options['oid_ancestors_table_name']} as a ON a.object_identity_id = o.id + {$this->options['oid_table_name']} o + INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id + INNER JOIN {$this->options['oid_ancestors_table_name']} a ON a.object_identity_id = o.id WHERE a.ancestor_id = %d AND a.object_identity_id != a.ancestor_id FINDCHILDREN; } else { $query = <<options['oid_table_name']} as o - INNER JOIN {$this->options['class_table_name']} as c ON c.id = o.class_id + FROM {$this->options['oid_table_name']} o + INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id WHERE o.parent_object_identity_id = %d FINDCHILDREN; } @@ -364,8 +365,8 @@ protected function getSelectObjectIdentityIdSql(ObjectIdentityInterface $oid) $query, $this->options['oid_table_name'], $this->options['class_table_name'], - $this->connection->quote($oid->getIdentifier()), - $this->connection->quote($oid->getType()) + $this->connection->quote((string) $oid->getIdentifier()), + $this->connection->quote((string) $oid->getType()) ); } @@ -420,8 +421,8 @@ private function getAncestorIds(array $batch) $ancestorIds = array(); foreach ($this->connection->executeQuery($sql)->fetchAll() as $data) { // FIXME: skip ancestors which are cached - - $ancestorIds[] = $data['ancestor_id']; + // Fix: Oracle returns key's in uppercase + $ancestorIds[] = reset($data); } return $ancestorIds; @@ -525,7 +526,7 @@ private function hydrateObjectIdentities(Statement $stmt, array $oidLookup, arra $auditSuccess, $auditFailure, $username, - $securityIdentifier) = $data; + $securityIdentifier) = array_values($data); // has the ACL been hydrated during this hydration cycle? if (isset($acls[$aclId])) { From 164ed925a746d27a4e0e7ed20d9768db578c1f91 Mon Sep 17 00:00:00 2001 From: Sergey Kolodyazhnyy Date: Wed, 4 Dec 2013 16:46:41 +0100 Subject: [PATCH 3/3] Typo in the comment --- src/Symfony/Component/Security/Acl/Dbal/AclProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php index 26d7da5c0ed69..1dc09c119637c 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php @@ -421,7 +421,7 @@ private function getAncestorIds(array $batch) $ancestorIds = array(); foreach ($this->connection->executeQuery($sql)->fetchAll() as $data) { // FIXME: skip ancestors which are cached - // Fix: Oracle returns key's in uppercase + // Fix: Oracle returns keys in uppercase $ancestorIds[] = reset($data); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy