Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 48fb0aa

Browse files
Sergey Kolodyazhnyyfabpot
authored andcommitted
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.
1 parent f5d9f31 commit 48fb0aa

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Acl/Dbal/AclProvider.php

Lines 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])) {

Acl/Dbal/MutableAclProvider.php

Lines 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)