Skip to content

Delete Class Ace #3715

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

Closed
samsamm777 opened this issue Mar 28, 2012 · 11 comments
Closed

Delete Class Ace #3715

samsamm777 opened this issue Mar 28, 2012 · 11 comments

Comments

@samsamm777
Copy link

Having some issues with this code...

    // creating the ACL
    $aclProvider = $this->get('security.acl.provider');
    $objectIdentity = new ObjectIdentity($acl->getClassIdentifer(), $acl->getClass());
    $currentAcl = $aclProvider->findAcl($objectIdentity);

    $classACEs = $currentAcl->getClassAces();
    foreach ( $classACEs as $index => $classACE ) {
        $currentAcl->deleteClassAce($index);                        
    }
    $aclProvider->updateAcl($currentAcl);

Im thinking there may be a bug in the deleteClassAce function? Gives an error "The index '1' does not exist."

@samsamm777
Copy link
Author

bump >.<

@stof
Copy link
Member

stof commented Mar 30, 2012

@schmittjoh ping

@jbergler
Copy link

jbergler commented May 6, 2012

Is the issue here that internally $index changes when an ACE is removed? I had a similar problem and solved it by iterating through the ACE's in reverse order.

@samsamm777
Copy link
Author

iterating through the array backwards worked.

$classACEs = $currentAcl->getObjectAces();
for ($i=(sizeof($classACEs)-1); $i>=0; $i--)
{
    $currentAcl->deleteObjectAce($i); 
}

its not ideal, but hey ho.

@yoannch
Copy link

yoannch commented May 24, 2012

@samsamm777 is that normal that when wanting to iterate through classes ACEs you perform a

$classesACEs = $currentAcl->getObjectAces();

(and then iterating on the object aces) instead of doing a

$classesACEs = $currentAcl->getClassAces();

?

I prefer to ask because at this point I wonder whether I'm mistaking or not using acls.

@tristanlins
Copy link

I got this error today.
The problem is, that if the ace order is broken - in my case [0, 2] - this error occures. I don't know why the order was broken, after fix the order manualy in the database, everything works fine.

@king724
Copy link

king724 commented Oct 17, 2013

I am also experiencing this issue. Symfony 2.1

@Codepadawan
Copy link

I had this same issue. In fact my indexes were ok, but when multiple indexes were deleted in one pass, it failed. Solved by reversing the order of the loop as described by @yoannch above

@samsamm777
Copy link
Author

@Codepadawan what symfony version are you using?

@Codepadawan
Copy link

2.4.2

@fabpot fabpot added Acl and removed Security labels Apr 28, 2014
@fabpot
Copy link
Member

fabpot commented Oct 5, 2015

Closing this issue as ACLs are not part of Symfony Core anymore (see #14718 for the initial discussion). It the issue still exists, you can create an issue on symfony/security-acl or symfony/acl-bundle. Thanks.

@fabpot fabpot closed this as completed Oct 5, 2015
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

8 participants