Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d6fccdd

Browse filesBrowse files
committed
feature #9690 Using Oracle Database as ACL storage (skolodyazhnyy)
This PR was squashed before being merged into the 2.5-dev branch (closes #9690). Discussion ---------- Using Oracle Database as ACL storage Hi, I have faced few errors when tried to use Oracle Database: 1. Oracle return result as an array where all column names are in uppercase, so some code, where column names was in lowercase stop working 2. Oracle gives me an error 'ORA-00933: SQL command not properly ended' for queries where 'AS' was used in FROM and JOIN instructions 3. Oracle require strict type match in queries, so I have added string converting for object_identity_id. Commits ------- 5f3be0e 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.
2 parents f66bed7 + 5f3be0e commit d6fccdd
Copy full SHA for d6fccdd

File tree

Expand file treeCollapse file tree

2 files changed

+16
-13
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-13
lines changed

‎src/Symfony/Component/Security/Acl/Dbal/AclProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Acl/Dbal/AclProvider.php
+14-12Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ public function findAcls(array $oids, array $sids = array())
194194
foreach ($oids as $oid) {
195195
if (!$result->contains($oid)) {
196196
if (1 === count($oids)) {
197-
throw new AclNotFoundException(sprintf('No ACL found for %s.', $oid));
197+
$objectName = method_exists($oid, '__toString') ? $oid : get_class($oid);
198+
throw new AclNotFoundException(sprintf('No ACL found for %s.', $objectName));
198199
}
199200

200201
$partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
@@ -283,7 +284,8 @@ protected function getAncestorLookupSql(array $batch)
283284
if (1 === count($types)) {
284285
$ids = array();
285286
for ($i = 0; $i < $count; $i++) {
286-
$ids[] = $this->connection->quote($batch[$i]->getIdentifier());
287+
$identifier = (string) $batch[$i]->getIdentifier();
288+
$ids[] = $this->connection->quote($identifier);
287289
}
288290

289291
$sql .= sprintf(
@@ -325,17 +327,17 @@ protected function getFindChildrenSql(ObjectIdentityInterface $oid, $directChild
325327
$query = <<<FINDCHILDREN
326328
SELECT o.object_identifier, c.class_type
327329
FROM
328-
{$this->options['oid_table_name']} as o
329-
INNER JOIN {$this->options['class_table_name']} as c ON c.id = o.class_id
330-
INNER JOIN {$this->options['oid_ancestors_table_name']} as a ON a.object_identity_id = o.id
330+
{$this->options['oid_table_name']} o
331+
INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id
332+
INNER JOIN {$this->options['oid_ancestors_table_name']} a ON a.object_identity_id = o.id
331333
WHERE
332334
a.ancestor_id = %d AND a.object_identity_id != a.ancestor_id
333335
FINDCHILDREN;
334336
} else {
335337
$query = <<<FINDCHILDREN
336338
SELECT o.object_identifier, c.class_type
337-
FROM {$this->options['oid_table_name']} as o
338-
INNER JOIN {$this->options['class_table_name']} as c ON c.id = o.class_id
339+
FROM {$this->options['oid_table_name']} o
340+
INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id
339341
WHERE o.parent_object_identity_id = %d
340342
FINDCHILDREN;
341343
}
@@ -363,8 +365,8 @@ protected function getSelectObjectIdentityIdSql(ObjectIdentityInterface $oid)
363365
$query,
364366
$this->options['oid_table_name'],
365367
$this->options['class_table_name'],
366-
$this->connection->quote($oid->getIdentifier()),
367-
$this->connection->quote($oid->getType())
368+
$this->connection->quote((string) $oid->getIdentifier()),
369+
$this->connection->quote((string) $oid->getType())
368370
);
369371
}
370372

@@ -419,8 +421,8 @@ private function getAncestorIds(array $batch)
419421
$ancestorIds = array();
420422
foreach ($this->connection->executeQuery($sql)->fetchAll() as $data) {
421423
// FIXME: skip ancestors which are cached
422-
423-
$ancestorIds[] = $data['ancestor_id'];
424+
// Fix: Oracle returns keys in uppercase
425+
$ancestorIds[] = reset($data);
424426
}
425427

426428
return $ancestorIds;
@@ -524,7 +526,7 @@ private function hydrateObjectIdentities(Statement $stmt, array $oidLookup, arra
524526
$auditSuccess,
525527
$auditFailure,
526528
$username,
527-
$securityIdentifier) = $data;
529+
$securityIdentifier) = array_values($data);
528530

529531
// has the ACL been hydrated during this hydration cycle?
530532
if (isset($acls[$aclId])) {

‎src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public function __construct(Connection $connection, PermissionGrantingStrategyIn
5151
public function createAcl(ObjectIdentityInterface $oid)
5252
{
5353
if (false !== $this->retrieveObjectIdentityPrimaryKey($oid)) {
54-
throw new AclAlreadyExistsException(sprintf('%s is already associated with an ACL.', $oid));
54+
$objectName = method_exists($oid, '__toString') ? $oid : get_class($oid);
55+
throw new AclAlreadyExistsException(sprintf('%s is already associated with an ACL.', $objectName));
5556
}
5657

5758
$this->connection->beginTransaction();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.