So I’m happily using the magento store the yesterday and when I tried to login to the admin area from a different computer than usual I got “Parent Role id ‘G4’ does not exist” and quite a bit more code… and that was it… Now the same problem has affected all computers that I’m trying to use to admin the site. Que pasa? This site has been working fine and there haven’t been any upgrade to Magento since I did a clean in stall of 1.1.1 and the modern theme. I’d like to correct this and upgrade to 1.1.3.
Oh, the front end and the downloader seem to still work fine. I have not considered using the downloader to upgrade the install, at least not until this issue is corrected. I was part of the 1.0 to 1.1 upgrade disaster and I’m not going to repeat that.
A complete overwrite had no effect. So, both a 1.1.1 to 1.1.3 upgrade and a clean install of 1.1.3 didn’t resolve the issues. I’m back to 1.1.1 while I continue to diagnose the problem.
i feel your pain....but i don’t think anyone knows the answer to your problem.
At least not anyone posting on the forums.
After spending quite a few hours digging through the database I was able to uncover the problem and resolve it. I’ll post my solution here so it may help someone else in the future.
First, some background and context. Magento uses at least 3 database tables to keep track of admin roles, users and roles. They are called admin_roles, admin_rules and admin_users. Within those three tables you’ll see defined your primary admin role (basically a ‘super-admin’). This is always G1, which I believe stands for ‘Group 1’. It is comprised of two items, role_type (either U or G) and role_id which is always a number and counts up with both roles and users.
Your first user will be an ‘U’ and have a parent_id of 1. The parent_id indicates which role\group the user is a part of and the ‘U’ indicates that this is a user and not a group.
The error “Parent Role id ‘G4’ does not exist” meant that Group 4 was broken. I didn’t take the time to track down exactly what db error was causing it to be broken in my case since I am satisfied to have it corrected. As you have probably guessed, G4 wasn’t the primary account, in fact it was a ‘sales \ support’ account I created for the invoicing and shipping needs of my place. Evidently when I created a new user account and assigned it to the G4 role it caused some form of corruption to just the G4 role and users.
Now, here’s where the developers need to make an adjustment. When Magento isn’t happy with a role, even if its a differnt level role then you are trying to login with, no one else is allowed to login. So, even though my account has much higher privileges than the G4 role I couldn’t login. A much more elegant failure would allow users of a different role to login and only block those with the specific issue.
To fix it I went into the three tables I mentioned above and deleted all references to roles and users except the G1 role and the first G1 user. Immediately I was granted access and all was well with the world. I’ll go through later today and recreate the other needed roles and users and I’ll post here if I find anything interesting.
So, problem solved by digging. How I wish there was ANY documentation on this in the wiki, forums or elsewhere. No where I could find anything on this issue. Varien has a lot of documentation to release still and I can’t wait till they do it.
Thanks SH, it took me many hours to find this information, the least I can do is make sure its publicly available to save someone else this problem.
Unfortunately when I went to recreate the admin roles I need for day to day admin of the site the same error poped up. Apparently there’s an underlying DB problem that is revealed whenever I try to setup those users. Its going to be quite a pain and something that will have to be resolved. I’ll post more when I have information.
I bumped into this problem too. After some digging I realized that magento reads the rows from the database table admin_role in the “wrong” order. That is it reads the user entry before the parent group (the role) is loaded. This happends because the user rows has a tree_level = 1, when they should have tree_level = 2 or more.
Solution:
To fix a broken admin-interface, run the following query in the magento database:
UPDATE admin_role SET tree_level = 2 WHERE role_type = “U”;
To prevent the error from happening again:
Open up the file app/code/core/Mage/Admin/Model/Mysql4/User.php
On line 162 (or close to that line) you find a row that says:
‘tree_level’ => $row[’tree_level’] + 1,
change this line to:
‘tree_level’ => $row[’tree_level’] + 2,
@ Ludvig: Thank you for digging in and posting your findings it helped me out too!
Yesterday I had the same weird experience of suddenly not being able to access the Magento back-end. After some browsing through the posts here I found your solution and it worked like a charm for me, thank you!
@ Ludvig : Thank you so much for your so great solution… I had the same problem several times without finding anything, the only solution I found was to delete all new users, it wasn’t important… but now I need them
It’s strange, it’s still not fixed even in new 1.1.7. Maybe Ludvig, you should report the bug and give the solution you found…