27

It is a very common error that shows in Magento when you install a new extension with system.xml config:

When you go to the System->Configuration->Extension tab, a 404 error is shown. You need to logout and login again and then it is ok. But is there any way to avoid this?

  • I don't believe so, the ACL tree is loaded when you log in and stored in the users session. – Peter O'Callaghan Jan 27 '14 at 9:56
  • I have one idea but I don't know if it is possible. You can change the behavior of "Magento Connect Manage" to expire all admin sessions after extension was installed. But its not possible to do from the scope of extension(((. Only from the scope of Connect Manager. – oleksii.svarychevskyi Jan 27 '14 at 10:33
  • 2
    Your question answered my question! Thanks! – Ian Phillips Jan 30 '15 at 19:12
  • I had to leave a comment, because as Ian said: "Your question answered my question". Logging did the trick! – Hans Wassink Mar 11 '15 at 14:06
16

As @Cags said, this is not (easily) possible because the ACL tree is loaded when the session is initialized (AKA when the admin logs in).
A possible workaround would be to override the _isSectionAllowed method in system configuration controller: (Mage_Adminhtml_System_ConfigController::_isSectionAllowed) and make it reload the ACL tree.
Something like:

protected function _isSectionAllowed($section)
{
    $session = Mage::getSingleton('admin/session');
    $session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());//reload the tree
    return parent::_isSectionAllowed($secntion); //all the code from the original method
}

But this means the ACL tree will be reloaded every time you access a config section. I see no point in doing this.
Also you cannot do it for one specific extension. You will have to rewrite the core class.

  • Maybe it would be better to only reset the ACL tree if the section is not allowed. I honestly can't ever recall trying to load a section that wasn't allowed by ACL other than after a module install and before the admin relogs. – pspahn Sep 15 '14 at 21:52
  • Just a crazy idea since I never tried it and I'm not sure if the session is available at this point, but could it be possible to reload from the install script? Of course this only works if the install script is triggered by a request where you as admin are logged in and it won't affect other logged in backend users – Fabian Schmengler Oct 19 '14 at 21:08
  • 2
    @fschmengler. I haven't tried it before, but I think it could work. Bunt honestly I don't think it's worth the trouble. – Marius Oct 20 '14 at 5:58
9

I found a way around this with very little customization. What we need is:

  1. A new controller action that reloads the ACL (without logging out and in), then redirects back to the previous page:

    class SSE_AclReload_Adminhtml_Permissions_AclReloadController extends Mage_Adminhtml_Controller_Action
    {
        public function indexAction()
        {
            $session = Mage::getSingleton('admin/session');
            $session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
            Mage::getSingleton('adminhtml/session')->addSuccess($this->__('ACL reloaded'));
            $this->_redirectReferer();
        }
    }
    
  2. A layout update for the admin_noroute handle. We will add a link to this new controller action directly on the admin 404 page:

    <layout version="0.1.0">
        <adminhtml_noroute>
            <reference name="content">
                <block type="adminhtml/template" name="content.aclReload" after="content.noRoute" template="sse_aclreload/button.phtml" />
            </reference>
        </adminhtml_noroute>
    </layout>
    
  3. And the template with the link:

    <a href="<?php echo $this->getUrl('adminhtml/permissions_aclReload/index'); ?>">
        <?php echo $this->__('Reload ACL'); ?>
    </a>
    

I threw it together into a small extension on Github: SSE_AclReload (adds the link also to the System > Permissions menu)

You could also try to reload the ACL automatically as soon as the admin/noroute action is dispatched, but I prefer to 1) know what's going on and 2) have a choice.

1

If You have any problem when you install new extension and get 404 error page then only one thing you need to do is go into System > Permissions > Roles. Just save the role and do not forget to clear var/cache and var/seesion And your problem has been resolved.

  • "clear var/session"? To log out all customers and empty their carts? Nope. – Fabian Schmengler Jun 28 '16 at 12:07
  • nup, just clear the session, in the var folder – Hiral Unadkat Jun 29 '16 at 12:02
  • Unfortunately this is the same. Except if you don't use the file session handler. In that case it does nothing because there are no files – Fabian Schmengler Jun 29 '16 at 12:05
  • Then you need to do is go into System > Permissions > Roles and save the role. – Hiral Unadkat Jun 29 '16 at 12:21
  • Which brings us to the other problem with your answer: even if it works, it is more effort than logging out and back in, which OP wants to avoid. – Fabian Schmengler Jun 29 '16 at 12:24
0

Try this:

  1. Go to Admin -> System -> Cache Management
  2. Select all the Cache Type
  3. Keep action as Refresh and hit submit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.