processwire / processwire-issues

ProcessWire issue reports.
44 stars 2 forks source link

Template 'permission' should be single language by default (install) #1898

Closed kixe closed 6 months ago

kixe commented 6 months ago

Short description of the issue

If LanguageSupport is enabled in a ProcessWire installation, the type of the "title" field has been changed to PageTitleLanguage. When a superuser installs a new module that generates new permissions, the description of the new "permission" is stored in the "title" in user language, but not in the default language.

Suggestion for a possible fix

Since this is not such a big problem, I would also not force ModulesInstaller::install() to store the permission description in the default language column. However, I would recommend disabling multi-language support for the permission template by default during installation. Just add $template->noLang = 1. This keeps the system flexible but prevents unexpected behavior.

https://github.com/processwire/processwire/blob/3cc76cc886a49313b4bfb9a1a904bd88d11b7cb7/site-blank/install/install.sql#L409

INSERT INTO `templates` (`id`, `name`, `fieldgroups_id`, `flags`, `cache_time`, `data`) VALUES('5', 'permission', '5', '8', '0', '{\"noChildren\":1,\"parentTemplates\":[2],\"slashUrls\":1,\"guestSearchable\":1,\"pageClass\":\"Permission\",\"noGlobal\":1,\"noMove\":1,\"noLang\":1,\"noTrash\":1,\"noSettings\":1,\"noChangeTemplate\":1,\"nameContentTab\":1}');

Setup/Environment

ryancramerdesign commented 6 months ago

@kixe I guess I think that the template should remain multi-language unless the user edits it and turns off multi-language for that template. But you are right that if a module defines permissions via its getModuleInfo() then the descriptions of those permissions should go in the default language. We already have code that covers that case, but I found it wasn't perfect, as it would only work for the first installed permission by the module. If there was more than one permission installed by the module, then the description might end up in the user's language rather than the default language. I've pushed a fix for to hopefully correct that issue. Thanks.

kixe commented 6 months ago

Thanks