Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving insertObjectAce throw an undefined index when entry does not exist in old objectAce #120

Open
nisiah78 opened this issue Jun 24, 2024 · 1 comment

Comments

@nisiah78
Copy link

Hello,

Here is our scenario that break our acl workflow when we want to add another mask entry for an user.
We have a flow that let our admin user to switch from their admin account to another access level temporarily.
Then by action we want to add the temporary access level on the acl entries through insertObjectAce and then save the action updateAcl, we got on some case an undefined index 0 or any index when it does not exists on the old value of the objectAce.

here is the part of the code

$objectsAce = $acl->getObjectAces();
$isUpdated = false;

        foreach ($objectsAce as $index => $objectAce) {

            /** @var Entry $objectAce */
            if ($securityIdentity->getUsername() !== $objectAce->getSecurityIdentity()->getUsername()) {
                continue;
            }

            $acl->updateObjectAce($index, $maskAccess);
            $isUpdated = true;
            break;
        }

        if (!$isUpdated) {
             $acl->insertObjectAce($securityIdentity, $maskAccess);
        }
@nisiah78
Copy link
Author

nisiah78 commented Jun 24, 2024

the error is in the updateOldAceProperty:963 (Symfony\Component\Security\Acl\Dbal\MutableAclProvider.php)

for ($i = 0, $c = \count($old); $i < $c; ++$i) {
            $ace = $old[$i]; <=== here comes the error when the content is not defined

            if (!isset($currentIds[$ace->getId()])) {
                $this->connection->executeStatement($this->getDeleteAccessControlEntrySql($ace->getId()));
                unset($this->loadedAces[$ace->getId()]);
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant