Notice: Undefined index: User roles in config_export_single_form()
Description of the bug
When trying to export a user role config, when following a link on the role overview page, PHP notices and warnings are thrown, if a language other than English is the current one and the string "User roles" has a translation.
Steps To Reproduce
- Turn on error display
- Enable language, locale (interface translation), add a language
- Go to admin/config/regional/translate/translate, search for "User roles" and translate it
- Go to OTHERLANGUAGE/admin/config/people/roles
- Click on any of the links to "Export role"
- You get redirected to admin/config/development/configuration/single/export
- The url contains "?group=User roles&name=user.role.whatevertherole"
- Page shows messages
Notice: Undefined index: User roles in config_export_single_form() (Zeile 308 von .../core/modules/config/config.admin.inc).
Warning: natsort() expects parameter 1 to be array, null given in config_export_single_form() (Zeile 309 von.../core/modules/config/config.admin.inc).
Warning: Invalid argument supplied for foreach() in form_select_options() (Zeile 2871 von .../core/includes/form.inc).
UPDATE: 4 years later the message slightly changed, but the base problem persists and the fix is still valid.
New notice:
Configuration group User roles not available.
Additional information
- Backdrop CMS version: discovered in 1.17.4 or 1.18.x-dev, still there in 1.29.x
- Web server and its version: apache 2.4
- PHP 7.4 and 7.3, 8.2... (turned out to be unrelated)
Still "discussing" with Zen.CI...
Anyway, a PR is available for testing and review.
BTW: I don't think that it's a good idea to use translated strings as array keys, but the same concept is used in function config_export_single_form(), or actually in config_get_prefix_groups().
Still "discussing" with Zen.CI...
IKR? 🤦 😞
Rebased this incredibly old PR - the bugfix is still valid. Don't have high hopes for attention here, but if someone needs a solution - here it is. :grinning:
Not that I think, using a translated string as GET param is smart in any way, but... :shrug:
I followed the steps reported in the issue summary. I tried translating a string without translation in the language I added, and changing an existing translation for the same language. I did not get any error shown in the user interface.
Thanks @indigoxela and @avpaderno! Strange fix for sure. I wouldn't say no to a more comprehensive fix that didn't use translated strings but that might be a lot more challenging. I merged https://github.com/backdrop/backdrop/pull/3432 into 1.x and 1.28.x as-is. Thank you!