backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 38 forks source link

Notice: Undefined index: User roles in config_export_single_form() #4795

Closed indigoxela closed 1 week ago

indigoxela commented 3 years ago

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

indigoxela commented 3 years ago

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

klonos commented 3 years ago

Still "discussing" with Zen.CI...

IKR? 🤦 😞

indigoxela commented 2 months ago

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:

avpaderno commented 2 months ago

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.

quicksketch commented 1 week ago

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!