vendor/symfony/security-acl/Dbal/AclProvider.php line 59

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Acl\Dbal;
  11. use Doctrine\DBAL\Connection;
  12. use Doctrine\DBAL\Result;
  13. use Symfony\Component\Security\Acl\Domain\Acl;
  14. use Symfony\Component\Security\Acl\Domain\Entry;
  15. use Symfony\Component\Security\Acl\Domain\FieldEntry;
  16. use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
  17. use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity;
  18. use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
  19. use Symfony\Component\Security\Acl\Exception\AclNotFoundException;
  20. use Symfony\Component\Security\Acl\Exception\NotAllAclsFoundException;
  21. use Symfony\Component\Security\Acl\Model\AclCacheInterface;
  22. use Symfony\Component\Security\Acl\Model\AclInterface;
  23. use Symfony\Component\Security\Acl\Model\AclProviderInterface;
  24. use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface;
  25. use Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface;
  26. /**
  27. * An ACL provider implementation.
  28. *
  29. * This provider assumes that all ACLs share the same PermissionGrantingStrategy.
  30. *
  31. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  32. */
  33. class AclProvider implements AclProviderInterface
  34. {
  35. public const MAX_BATCH_SIZE = 30;
  36. /**
  37. * @var AclCacheInterface|null
  38. */
  39. protected $cache;
  40. /**
  41. * @var Connection
  42. */
  43. protected $connection;
  44. protected $loadedAces = [];
  45. protected $loadedAcls = [];
  46. protected $options;
  47. /**
  48. * @var PermissionGrantingStrategyInterface
  49. */
  50. private $permissionGrantingStrategy;
  51. public function __construct(Connection $connection, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $options, AclCacheInterface $cache = null)
  52. {
  53. $this->cache = $cache;
  54. $this->connection = $connection;
  55. $this->options = $options;
  56. $this->permissionGrantingStrategy = $permissionGrantingStrategy;
  57. }
  58. /**
  59. * {@inheritdoc}
  60. */
  61. public function findChildren(ObjectIdentityInterface $parentOid, $directChildrenOnly = false)
  62. {
  63. $sql = $this->getFindChildrenSql($parentOid, $directChildrenOnly);
  64. $children = [];
  65. foreach ($this->connection->executeQuery($sql)->fetchAllAssociative() as $data) {
  66. $children[] = new ObjectIdentity($data['object_identifier'], $data['class_type']);
  67. }
  68. return $children;
  69. }
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function findAcl(ObjectIdentityInterface $oid, array $sids = [])
  74. {
  75. return $this->findAcls([$oid], $sids)->offsetGet($oid);
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public function findAcls(array $oids, array $sids = [])
  81. {
  82. /** @var \SplObjectStorage<ObjectIdentityInterface,AclInterface> */
  83. $result = new \SplObjectStorage();
  84. $currentBatch = [];
  85. $oidLookup = [];
  86. for ($i = 0, $c = \count($oids); $i < $c; ++$i) {
  87. $oid = $oids[$i];
  88. $oidLookupKey = $oid->getIdentifier().$oid->getType();
  89. $oidLookup[$oidLookupKey] = $oid;
  90. $aclFound = false;
  91. // check if result already contains an ACL
  92. if ($result->contains($oid)) {
  93. $aclFound = true;
  94. }
  95. // check if this ACL has already been hydrated
  96. if (!$aclFound && isset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()])) {
  97. $acl = $this->loadedAcls[$oid->getType()][$oid->getIdentifier()];
  98. if (!$acl->isSidLoaded($sids)) {
  99. // FIXME: we need to load ACEs for the missing SIDs. This is never
  100. // reached by the default implementation, since we do not
  101. // filter by SID
  102. throw new \RuntimeException('This is not supported by the default implementation.');
  103. } else {
  104. $result->attach($oid, $acl);
  105. $aclFound = true;
  106. }
  107. }
  108. // check if we can locate the ACL in the cache
  109. if (!$aclFound && null !== $this->cache) {
  110. $acl = $this->cache->getFromCacheByIdentity($oid);
  111. if (null !== $acl) {
  112. if ($acl->isSidLoaded($sids)) {
  113. // check if any of the parents has been loaded since we need to
  114. // ensure that there is only ever one ACL per object identity
  115. $parentAcl = $acl->getParentAcl();
  116. while (null !== $parentAcl) {
  117. $parentOid = $parentAcl->getObjectIdentity();
  118. if (isset($this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()])) {
  119. $acl->setParentAcl($this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()]);
  120. break;
  121. } else {
  122. $this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()] = $parentAcl;
  123. $this->updateAceIdentityMap($parentAcl);
  124. }
  125. $parentAcl = $parentAcl->getParentAcl();
  126. }
  127. $this->loadedAcls[$oid->getType()][$oid->getIdentifier()] = $acl;
  128. $this->updateAceIdentityMap($acl);
  129. $result->attach($oid, $acl);
  130. $aclFound = true;
  131. } else {
  132. $this->cache->evictFromCacheByIdentity($oid);
  133. foreach ($this->findChildren($oid) as $childOid) {
  134. $this->cache->evictFromCacheByIdentity($childOid);
  135. }
  136. }
  137. }
  138. }
  139. // looks like we have to load the ACL from the database
  140. if (!$aclFound) {
  141. $currentBatch[] = $oid;
  142. }
  143. // Is it time to load the current batch?
  144. $currentBatchesCount = \count($currentBatch);
  145. if ($currentBatchesCount > 0 && (self::MAX_BATCH_SIZE === $currentBatchesCount || ($i + 1) === $c)) {
  146. try {
  147. $loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup);
  148. } catch (AclNotFoundException $e) {
  149. if ($result->count()) {
  150. $partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
  151. $partialResultException->setPartialResult($result);
  152. throw $partialResultException;
  153. } else {
  154. throw $e;
  155. }
  156. }
  157. foreach ($loadedBatch as $loadedOid) {
  158. $loadedAcl = $loadedBatch->offsetGet($loadedOid);
  159. if (null !== $this->cache) {
  160. $this->cache->putInCache($loadedAcl);
  161. }
  162. if (isset($oidLookup[$loadedOid->getIdentifier().$loadedOid->getType()])) {
  163. $result->attach($loadedOid, $loadedAcl);
  164. }
  165. }
  166. $currentBatch = [];
  167. }
  168. }
  169. // check that we got ACLs for all the identities
  170. foreach ($oids as $oid) {
  171. if (!$result->contains($oid)) {
  172. if (1 === \count($oids)) {
  173. $objectName = method_exists($oid, '__toString') ? $oid : \get_class($oid);
  174. throw new AclNotFoundException(sprintf('No ACL found for %s.', $objectName));
  175. }
  176. $partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
  177. $partialResultException->setPartialResult($result);
  178. throw $partialResultException;
  179. }
  180. }
  181. return $result;
  182. }
  183. /**
  184. * Constructs the query used for looking up object identities and associated
  185. * ACEs, and security identities.
  186. *
  187. * @return string
  188. */
  189. protected function getLookupSql(array $ancestorIds)
  190. {
  191. // FIXME: add support for filtering by sids (right now we select all sids)
  192. $sql = <<<SELECTCLAUSE
  193. SELECT
  194. o.id as acl_id,
  195. o.object_identifier,
  196. o.parent_object_identity_id,
  197. o.entries_inheriting,
  198. c.class_type,
  199. e.id as ace_id,
  200. e.object_identity_id,
  201. e.field_name,
  202. e.ace_order,
  203. e.mask,
  204. e.granting,
  205. e.granting_strategy,
  206. e.audit_success,
  207. e.audit_failure,
  208. s.username,
  209. s.identifier as security_identifier
  210. FROM
  211. {$this->options['oid_table_name']} o
  212. INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id
  213. LEFT JOIN {$this->options['entry_table_name']} e ON (
  214. e.class_id = o.class_id AND (e.object_identity_id = o.id OR e.object_identity_id IS NULL)
  215. )
  216. LEFT JOIN {$this->options['sid_table_name']} s ON (
  217. s.id = e.security_identity_id
  218. )
  219. WHERE (o.id =
  220. SELECTCLAUSE;
  221. $sql .= implode(' OR o.id = ', $ancestorIds).')';
  222. return $sql;
  223. }
  224. protected function getAncestorLookupSql(array $batch)
  225. {
  226. $sql = <<<SELECTCLAUSE
  227. SELECT a.ancestor_id
  228. FROM
  229. {$this->options['oid_table_name']} o
  230. INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id
  231. INNER JOIN {$this->options['oid_ancestors_table_name']} a ON a.object_identity_id = o.id
  232. WHERE (
  233. SELECTCLAUSE;
  234. $types = [];
  235. $count = \count($batch);
  236. for ($i = 0; $i < $count; ++$i) {
  237. if (!isset($types[$batch[$i]->getType()])) {
  238. $types[$batch[$i]->getType()] = true;
  239. // if there is more than one type we can safely break out of the
  240. // loop, because it is the differentiator factor on whether to
  241. // query for only one or more class types
  242. if (\count($types) > 1) {
  243. break;
  244. }
  245. }
  246. }
  247. if (1 === \count($types)) {
  248. $ids = [];
  249. for ($i = 0; $i < $count; ++$i) {
  250. $identifier = (string) $batch[$i]->getIdentifier();
  251. $ids[] = $this->connection->quote($identifier);
  252. }
  253. $sql .= sprintf(
  254. '(o.object_identifier IN (%s) AND c.class_type = %s)',
  255. implode(',', $ids),
  256. $this->connection->quote($batch[0]->getType())
  257. );
  258. } else {
  259. $where = '(o.object_identifier = %s AND c.class_type = %s)';
  260. for ($i = 0; $i < $count; ++$i) {
  261. $sql .= sprintf(
  262. $where,
  263. $this->connection->quote($batch[$i]->getIdentifier()),
  264. $this->connection->quote($batch[$i]->getType())
  265. );
  266. if ($i + 1 < $count) {
  267. $sql .= ' OR ';
  268. }
  269. }
  270. }
  271. $sql .= ')';
  272. return $sql;
  273. }
  274. /**
  275. * Constructs the SQL for retrieving child object identities for the given
  276. * object identities.
  277. *
  278. * @param bool $directChildrenOnly
  279. *
  280. * @return string
  281. */
  282. protected function getFindChildrenSql(ObjectIdentityInterface $oid, $directChildrenOnly)
  283. {
  284. if (false === $directChildrenOnly) {
  285. $query = <<<FINDCHILDREN
  286. SELECT o.object_identifier, c.class_type
  287. FROM
  288. {$this->options['oid_table_name']} o
  289. INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id
  290. INNER JOIN {$this->options['oid_ancestors_table_name']} a ON a.object_identity_id = o.id
  291. WHERE
  292. a.ancestor_id = %d AND a.object_identity_id != a.ancestor_id
  293. FINDCHILDREN;
  294. } else {
  295. $query = <<<FINDCHILDREN
  296. SELECT o.object_identifier, c.class_type
  297. FROM {$this->options['oid_table_name']} o
  298. INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id
  299. WHERE o.parent_object_identity_id = %d
  300. FINDCHILDREN;
  301. }
  302. return sprintf($query, $this->retrieveObjectIdentityPrimaryKey($oid));
  303. }
  304. /**
  305. * Constructs the SQL for retrieving the primary key of the given object
  306. * identity.
  307. *
  308. * @return string
  309. */
  310. protected function getSelectObjectIdentityIdSql(ObjectIdentityInterface $oid)
  311. {
  312. $query = <<<QUERY
  313. SELECT o.id
  314. FROM %s o
  315. INNER JOIN %s c ON c.id = o.class_id
  316. WHERE o.object_identifier = %s AND c.class_type = %s
  317. QUERY;
  318. return sprintf(
  319. $query,
  320. $this->options['oid_table_name'],
  321. $this->options['class_table_name'],
  322. $this->connection->quote((string) $oid->getIdentifier()),
  323. $this->connection->quote((string) $oid->getType())
  324. );
  325. }
  326. /**
  327. * Returns the primary key of the passed object identity.
  328. *
  329. * @return int
  330. */
  331. final protected function retrieveObjectIdentityPrimaryKey(ObjectIdentityInterface $oid)
  332. {
  333. return $this->connection->executeQuery($this->getSelectObjectIdentityIdSql($oid))->fetchOne();
  334. }
  335. /**
  336. * This method is called when an ACL instance is retrieved from the cache.
  337. */
  338. private function updateAceIdentityMap(AclInterface $acl)
  339. {
  340. foreach (['classAces', 'classFieldAces', 'objectAces', 'objectFieldAces'] as $property) {
  341. $reflection = new \ReflectionProperty($acl, $property);
  342. $reflection->setAccessible(true);
  343. $value = $reflection->getValue($acl);
  344. if ('classAces' === $property || 'objectAces' === $property) {
  345. $this->doUpdateAceIdentityMap($value);
  346. } else {
  347. foreach ($value as $field => $aces) {
  348. $this->doUpdateAceIdentityMap($value[$field]);
  349. }
  350. }
  351. $reflection->setValue($acl, $value);
  352. $reflection->setAccessible(false);
  353. }
  354. }
  355. /**
  356. * Retrieves all the ids which need to be queried from the database
  357. * including the ids of parent ACLs.
  358. *
  359. * @return array
  360. */
  361. private function getAncestorIds(array $batch)
  362. {
  363. $sql = $this->getAncestorLookupSql($batch);
  364. $ancestorIds = [];
  365. foreach ($this->connection->executeQuery($sql)->fetchAllAssociative() as $data) {
  366. // FIXME: skip ancestors which are cached
  367. // Fix: Oracle returns keys in uppercase
  368. $ancestorIds[] = reset($data);
  369. }
  370. return $ancestorIds;
  371. }
  372. /**
  373. * Does either overwrite the passed ACE, or saves it in the global identity
  374. * map to ensure every ACE only gets instantiated once.
  375. */
  376. private function doUpdateAceIdentityMap(array &$aces)
  377. {
  378. foreach ($aces as $index => $ace) {
  379. if (isset($this->loadedAces[$ace->getId()])) {
  380. $aces[$index] = $this->loadedAces[$ace->getId()];
  381. } else {
  382. $this->loadedAces[$ace->getId()] = $ace;
  383. }
  384. }
  385. }
  386. /**
  387. * This method is called for object identities which could not be retrieved
  388. * from the cache, and for which thus a database query is required.
  389. *
  390. * @return \SplObjectStorage<ObjectIdentityInterface,AclInterface> mapping object identities to ACL instances
  391. *
  392. * @throws AclNotFoundException
  393. */
  394. private function lookupObjectIdentities(array $batch, array $sids, array $oidLookup)
  395. {
  396. $ancestorIds = $this->getAncestorIds($batch);
  397. if (!$ancestorIds) {
  398. throw new AclNotFoundException('There is no ACL for the given object identity.');
  399. }
  400. $sql = $this->getLookupSql($ancestorIds);
  401. $stmt = $this->connection->executeQuery($sql);
  402. return $this->hydrateObjectIdentities($stmt, $oidLookup, $sids);
  403. }
  404. /**
  405. * This method is called to hydrate ACLs and ACEs.
  406. *
  407. * This method was designed for performance; thus, a lot of code has been
  408. * inlined at the cost of readability, and maintainability.
  409. *
  410. * Keep in mind that changes to this method might severely reduce the
  411. * performance of the entire ACL system.
  412. *
  413. * @return \SplObjectStorage<ObjectIdentityInterface,AclInterface>
  414. *
  415. * @throws \RuntimeException
  416. */
  417. private function hydrateObjectIdentities(Result $stmt, array $oidLookup, array $sids)
  418. {
  419. /** @var \SplObjectStorage<Acl,string> */
  420. $parentIdToFill = new \SplObjectStorage();
  421. $acls = $aces = $emptyArray = [];
  422. $oidCache = $oidLookup;
  423. /** @var \SplObjectStorage<ObjectIdentityInterface,AclInterface> */
  424. $result = new \SplObjectStorage();
  425. $loadedAces = &$this->loadedAces;
  426. $loadedAcls = &$this->loadedAcls;
  427. $permissionGrantingStrategy = $this->permissionGrantingStrategy;
  428. // we need these to set protected properties on hydrated objects
  429. $aclReflection = new \ReflectionClass(Acl::class);
  430. $aclClassAcesProperty = $aclReflection->getProperty('classAces');
  431. $aclClassAcesProperty->setAccessible(true);
  432. $aclClassFieldAcesProperty = $aclReflection->getProperty('classFieldAces');
  433. $aclClassFieldAcesProperty->setAccessible(true);
  434. $aclObjectAcesProperty = $aclReflection->getProperty('objectAces');
  435. $aclObjectAcesProperty->setAccessible(true);
  436. $aclObjectFieldAcesProperty = $aclReflection->getProperty('objectFieldAces');
  437. $aclObjectFieldAcesProperty->setAccessible(true);
  438. $aclParentAclProperty = $aclReflection->getProperty('parentAcl');
  439. $aclParentAclProperty->setAccessible(true);
  440. // fetchAll() consumes more memory than consecutive calls to fetch(),
  441. // but it is faster
  442. foreach ($stmt->fetchAllNumeric() as $data) {
  443. [$aclId,
  444. $objectIdentifier,
  445. $parentObjectIdentityId,
  446. $entriesInheriting,
  447. $classType,
  448. $aceId,
  449. $objectIdentityId,
  450. $fieldName,
  451. $aceOrder,
  452. $mask,
  453. $granting,
  454. $grantingStrategy,
  455. $auditSuccess,
  456. $auditFailure,
  457. $username,
  458. $securityIdentifier] = array_values($data);
  459. // FIX: remove duplicate slashes
  460. $classType = str_replace('\\\\', '\\', $classType);
  461. // has the ACL been hydrated during this hydration cycle?
  462. if (isset($acls[$aclId])) {
  463. $acl = $acls[$aclId];
  464. // has the ACL been hydrated during any previous cycle, or was possibly loaded
  465. // from cache?
  466. } elseif (isset($loadedAcls[$classType][$objectIdentifier])) {
  467. $acl = $loadedAcls[$classType][$objectIdentifier];
  468. // keep reference in local array (saves us some hash calculations)
  469. $acls[$aclId] = $acl;
  470. // attach ACL to the result set; even though we do not enforce that every
  471. // object identity has only one instance, we must make sure to maintain
  472. // referential equality with the oids passed to findAcls()
  473. $oidCacheKey = $objectIdentifier.$classType;
  474. if (!isset($oidCache[$oidCacheKey])) {
  475. $oidCache[$oidCacheKey] = $acl->getObjectIdentity();
  476. }
  477. $result->attach($oidCache[$oidCacheKey], $acl);
  478. // so, this hasn't been hydrated yet
  479. } else {
  480. // create object identity if we haven't done so yet
  481. $oidLookupKey = $objectIdentifier.$classType;
  482. if (!isset($oidCache[$oidLookupKey])) {
  483. $oidCache[$oidLookupKey] = new ObjectIdentity($objectIdentifier, $classType);
  484. }
  485. $acl = new Acl((int) $aclId, $oidCache[$oidLookupKey], $permissionGrantingStrategy, $emptyArray, (bool) $entriesInheriting);
  486. // keep a local, and global reference to this ACL
  487. $loadedAcls[$classType][$objectIdentifier] = $acl;
  488. $acls[$aclId] = $acl;
  489. // try to fill in parent ACL, or defer until all ACLs have been hydrated
  490. if (null !== $parentObjectIdentityId) {
  491. if (isset($acls[$parentObjectIdentityId])) {
  492. $aclParentAclProperty->setValue($acl, $acls[$parentObjectIdentityId]);
  493. } else {
  494. $parentIdToFill->attach($acl, $parentObjectIdentityId);
  495. }
  496. }
  497. $result->attach($oidCache[$oidLookupKey], $acl);
  498. }
  499. // check if this row contains an ACE record
  500. if (null !== $aceId) {
  501. // have we already hydrated ACEs for this ACL?
  502. if (!isset($aces[$aclId])) {
  503. $aces[$aclId] = [$emptyArray, $emptyArray, $emptyArray, $emptyArray];
  504. }
  505. // has this ACE already been hydrated during a previous cycle, or
  506. // possible been loaded from cache?
  507. // It is important to only ever have one ACE instance per actual row since
  508. // some ACEs are shared between ACL instances
  509. if (!isset($loadedAces[$aceId])) {
  510. if (!isset($sids[$key = ($username ? '1' : '0').$securityIdentifier])) {
  511. if ($username) {
  512. $sids[$key] = new UserSecurityIdentity(
  513. substr($securityIdentifier, 1 + $pos = strpos($securityIdentifier, '-')),
  514. substr($securityIdentifier, 0, $pos)
  515. );
  516. } else {
  517. $sids[$key] = new RoleSecurityIdentity($securityIdentifier);
  518. }
  519. }
  520. if (null === $fieldName) {
  521. $loadedAces[$aceId] = new Entry((int) $aceId, $acl, $sids[$key], $grantingStrategy, (int) $mask, (bool) $granting, (bool) $auditFailure, (bool) $auditSuccess);
  522. } else {
  523. $loadedAces[$aceId] = new FieldEntry((int) $aceId, $acl, $fieldName, $sids[$key], $grantingStrategy, (int) $mask, (bool) $granting, (bool) $auditFailure, (bool) $auditSuccess);
  524. }
  525. }
  526. $ace = $loadedAces[$aceId];
  527. // assign ACE to the correct property
  528. if (null === $objectIdentityId) {
  529. if (null === $fieldName) {
  530. $aces[$aclId][0][$aceOrder] = $ace;
  531. } else {
  532. $aces[$aclId][1][$fieldName][$aceOrder] = $ace;
  533. }
  534. } else {
  535. if (null === $fieldName) {
  536. $aces[$aclId][2][$aceOrder] = $ace;
  537. } else {
  538. $aces[$aclId][3][$fieldName][$aceOrder] = $ace;
  539. }
  540. }
  541. }
  542. }
  543. // We do not sort on database level since we only want certain subsets to be sorted,
  544. // and we are going to read the entire result set anyway.
  545. // Sorting on DB level increases query time by an order of magnitude while it is
  546. // almost negligible when we use PHPs array sort functions.
  547. foreach ($aces as $aclId => $aceData) {
  548. $acl = $acls[$aclId];
  549. ksort($aceData[0]);
  550. $aclClassAcesProperty->setValue($acl, $aceData[0]);
  551. foreach (array_keys($aceData[1]) as $fieldName) {
  552. ksort($aceData[1][$fieldName]);
  553. }
  554. $aclClassFieldAcesProperty->setValue($acl, $aceData[1]);
  555. ksort($aceData[2]);
  556. $aclObjectAcesProperty->setValue($acl, $aceData[2]);
  557. foreach (array_keys($aceData[3]) as $fieldName) {
  558. ksort($aceData[3][$fieldName]);
  559. }
  560. $aclObjectFieldAcesProperty->setValue($acl, $aceData[3]);
  561. }
  562. // fill-in parent ACLs where this hasn't been done yet cause the parent ACL was not
  563. // yet available
  564. $processed = 0;
  565. foreach ($parentIdToFill as $acl) {
  566. $parentId = $parentIdToFill->offsetGet($acl);
  567. // let's see if we have already hydrated this
  568. if (isset($acls[$parentId])) {
  569. $aclParentAclProperty->setValue($acl, $acls[$parentId]);
  570. ++$processed;
  571. continue;
  572. }
  573. }
  574. // reset reflection changes
  575. $aclClassAcesProperty->setAccessible(false);
  576. $aclClassFieldAcesProperty->setAccessible(false);
  577. $aclObjectAcesProperty->setAccessible(false);
  578. $aclObjectFieldAcesProperty->setAccessible(false);
  579. $aclParentAclProperty->setAccessible(false);
  580. // this should never be true if the database integrity hasn't been compromised
  581. if ($processed < \count($parentIdToFill)) {
  582. throw new \RuntimeException('Not all parent ids were populated. This implies an integrity problem.');
  583. }
  584. return $result;
  585. }
  586. }