Magento2: Can't edit or add new user role

Created on 24 Oct 2016  路  27Comments  路  Source: magento/magento2

I try to create a new user role and the initial page is blank and when I hit save role, I get the following error:

Notice: Undefined index: rolename in httpdocs/vendor/magento/module-user/Controller/Adminhtml/User/Role/SaveRole.php on line 213

Preconditions

  1. Magento Version 2.1

Steps to reproduce

  1. Click on Add New Role
  2. Page is blank except for save role so clicking on that is the only option

Expected result

  1. That settings area for new role would show up
    ### Actual result
  2. I attached a screenshot
    screenshot_magento
  3. I attached my acl.xml showing that it is correct
    acl.txt

Cannot Reproduce Clear Description Format is valid bug report

Most helpful comment

I had same error coz one of modules wasnt developed correctly. Problem was in etc/acl.xml
One of the tags there had no required title="" attribute available.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::system">
                    <resource id="Magento_Backend::tools">
                        <resource id="Magento_Backup::backup">
                            <resource id="Vendor_MyModule::rollback" />
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>

when i added title="Rollback" translate="title" & cleared cache i was able to add/edit roles again.

Magento ver. 2.1.2

All 27 comments

Hi @ooples, I cannot reproduce this issue.
Try to clear browser local cache

I can confirm this behaviour in Magento 2.1.2.

system.log shows the following error:

[2016-11-01 08:25:57] main.CRITICAL: Notice: Undefined index: title in .../vendor/magento/module-integration/Helper/Data.php on line 24 []

I can confirm the same problem in Magento 2.1.2 on PHP 7 using Chrome.

Notice: Undefined index: rolename in /home/xxxxxx/public_html/vendor/magento/module-user/Controller/Adminhtml/User/Role/SaveRole.php on line 213

I get this if I click the "save roll" button.

Can a role be added manually in the interim?

I'm having the same issue since upgrading to 2.1.2 - 2.1.1 worked fine. Clearing cache did not help, the form just will not load.

Is there a workaround? Since the issue is already becoming old...

Not that I am aware of.

Quite disturbing I might say. You should think there would a patch or something by now.

There is a sort of work around. Install 2.1.0, add the roles as needed, then upgrade to 2.1.3. Not much of a work around mind you.

Yeah, nice workaround ;-)

@spyrule : I really hope you're joking... Nevertheless. In Magento 2.1.3 I'm still not able to add a new user role. The error however has slightly changed:

Exception #0 (Exception): Notice: Undefined index: title in /var/www/public/vendor/magento/module-integration/Helper/Data.php on line 24

So can we have any word on this from the Magento Community? Is there already an internal ticket for this? Not being able to create user roles is pretty deal-breaking and this has been an issue for a while now...

I also am experiencing the same issue as @kanduvisla - we can open a seperate issue if thats required.

I tested in a fresh install of 2.1.3 on apache, php 7 & Mysql 5.7 and it does NOT happen on a clean, out of the box install.

It appears after installing 3rd party modules. So now I will isolate which 3rd party modules are causing the issue[s]. Ill report back if I find anything more.

Can you give a list of extensions you use? Maybe there is one I use too?

I had same error coz one of modules wasnt developed correctly. Problem was in etc/acl.xml
One of the tags there had no required title="" attribute available.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::system">
                    <resource id="Magento_Backend::tools">
                        <resource id="Magento_Backup::backup">
                            <resource id="Vendor_MyModule::rollback" />
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>

when i added title="Rollback" translate="title" & cleared cache i was able to add/edit roles again.

Magento ver. 2.1.2

I've checked every extension I've got but none is missing a title tag. Though I don't really understand why in your example the second last resource tag has a title but the last resource tag doesn't. Can you explain?

Have updated my codeblock.
Thats the reason why my roles wasnt working. Last <resource> tag needs title="" so it must look like this <resource id="Vendor_MyModule::rollback" title="Rollback" translate="title" />.

What i should recommend you is to switch off 1 by 1 3rd-party modules so you can see what module gives you conflicts.
Dont forget to clear your cache.

So, to check. Every "resource" tag no matter which depth should have a title attribute?

@Frits1980 ; What extensions do u use? Did you manage to solve it?

Nevermind i solved it, it with the information of @blewinsky . I tried an extension Emagicone Mobile assistant. was missing the title -> file : app/code/Emagicone/Mobassistantconnector/etc/acl.xml

before:
<resource id="Emagicone_Mobassistantconnector::settings">

after:
<resource id="Emagicone_Mobassistantconnector::settings" title="Emagicone">

If all the community and custom modules have a title attribute within the resource (i.e. <resource id="Example_Module::custom" title="Example Module - Custom">) then you may wanna try the trick of overriding the \Magento\User\Block\Role\Tab\Edit::getTree() method suggested in #7101:

Before:

    /**
     * Get Json Representation of Resource Tree
     *
     * @return array
     */
    public function getTree()
    {
        $resources = $this->_aclResourceProvider->getAclResources();
        $rootArray = $this->_integrationData->mapResources(
            isset($resources[1]['children']) ? $resources[1]['children'] : []
        );
        return $rootArray;
    }

After:

    /**
     * Get Json Representation of Resource Tree
     *
     * @return array
     */
    public function getTree()
    {
        $resources = $this->_aclResourceProvider->getAclResources();
        $rootArray = $this->_integrationData->mapResources(
            isset($resources[2]['children']) ? $resources[2]['children'] : []
        );
        return $rootArray;
    }

Here are the steps how I identified the faulty acl.xml:
1) Overridden the helper file in di.xml of my custom module

2) Created file named as ExtendIntegrationData.php at VENDORNAME\MODULENAME\Helper
Then overridden function mapResources() in it as below:

public function mapResources(array $resources)
{
$output = [];
foreach ($resources as $resource) {

        if (!isset($resource['title'])) {
            echo "<xmp>";
            print_r($resource);
            die;
        }


        $item = [];
        $item['attr']['data-id'] = $resource['id'];
        $item['data'] = $resource['title'];
        $item['children'] = [];
        if (isset($resource['children'])) {
            $item['state'] = 'open';
            $item['children'] = $this->mapResources($resource['children']);
        }
        $output[] = $item;
    }
    return $output;
}

In view source, I got the array of faulty acl statements. I corrected acl.xml of those modules and then removed the debugging statement from above function. The modules are mostly developed by Solwin vendors i.e. Contactwidget, PrevNext & Printpage.

@Geert82 I ended up removing every extension 1 by 1 to figure out that it was a free extension made by Solwin. The most useless extension ever extualy. https://www.solwininfotech.com/product/magento-2-extensions/scroll-to-top-magento-2/

I can confirm, when we removed our Solwin extension (Contact Widget), we regained access to our user roles.

To bad that Solwin just doesn't live up to coding standards.

I found that this bug occur because some title tag of tag in acl.xml is missed.

@ooples, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.1.9

Same problem in magento 2.2.2
System Log Error

[2018-01-23 09:27:53] main.CRITICAL: Notice: Undefined index: title in /var/www/html/vendor/magento/module-integration/Helper/Data.php on line 24 [] []

Was this page helpful?
0 / 5 - 0 ratings