backdrop-issues icon indicating copy to clipboard operation
backdrop-issues copied to clipboard

Notice: Undefined index: User roles in config_export_single_form()

Open indigoxela opened this issue 5 years ago • 4 comments

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

  1. Turn on error display
  2. Enable language, locale (interface translation), add a language
  3. Go to admin/config/regional/translate/translate, search for "User roles" and translate it
  4. Go to OTHERLANGUAGE/admin/config/people/roles
  5. Click on any of the links to "Export role"
  6. You get redirected to admin/config/development/configuration/single/export
  7. The url contains "?group=User roles&name=user.role.whatevertherole"
  8. 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)

indigoxela avatar Dec 09 '20 16:12 indigoxela

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().

indigoxela avatar Dec 10 '20 10:12 indigoxela

Still "discussing" with Zen.CI...

IKR? 🤦 😞

klonos avatar Dec 10 '20 15:12 klonos

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:

indigoxela avatar Jun 24 '24 10:06 indigoxela

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.

avpaderno avatar Jun 24 '24 10:06 avpaderno

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!

quicksketch avatar Aug 19 '24 02:08 quicksketch