[Bug]: Resource manager causes error 500

Aperta
#7,604 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
54/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Start with the Resource Manager /API/ResourceManager/Items/GetRoles path and compare its role lookup and caching behavior with the fix in issue #6133 for the Persona Bar and PermissionsGrid. Trace how localized role names reach the roles cache and AdvancedPermissionProvider.GetOrCreateAdvancedRole; done means localized role names no longer corrupt role lookups or cause page requests to return HTTP 500.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Status: New
Is there an existing issue for this?
  • I have searched the existing issues
What happened?

On a site whose UI culture localizes role names (fr-FR : GlobalResources.fr-FR.resx ships Content Editors.Role = "Éditeurs de contenu"), the whole site starts returning HTTP 500 on every page, anonymous visitors included, and only an app pool recycle brings it back.

The same issue was fixed for the Persona Bar and PermissionsGrid in #6133 ("Fixes to avoid RoleName localization bleeding into the roles cache"), but the Resource Manager was not covered. Other code that looks a role up by name is affected too, e.g. GetRoleByName(portalId, "Administrators") returns null while the cache is corrupted.

Steps to reproduce?
  1. DNN 10.3.3, portal with fr-FR enabled (default GlobalResources.fr-FR.resx, which contains Content Editors.Role).
  2. Log in as an administrator with the UI in French.
  3. Open the Resource Manager and try to modify a folder name (role names are displayed localized on second tab), then save.
  4. Browse any page of the site.

Confirmed in production: the IIS logs show a call to /API/ResourceManager/Items/GetRoles just before the first 500.

Current Behavior

Every page returns 500 until the app pool is recycled (some users already logged may see part of the content with 500 errors on modules):

System.ArgumentException: System.Data.SqlClient.SqlException (0x80131904): Violation of UNIQUE KEY constraint 'IX_RoleName'. Cannot insert duplicate key in object 'dbo.Roles'. The duplicate key value is (0, Content Editors).
   at DotNetNuke.Security.Roles.DNNRoleProvider.CreateRole(RoleInfo role)
   at DotNetNuke.Security.Roles.RoleController.DotNetNuke.Security.Roles.IRoleController.AddRole(RoleInfo role, Boolean addToExistUsers)
   at DotNetNuke.Security.Permissions.AdvancedPermissionProvider.GetOrCreateAdvancedRole(Int32 portalId, String roleName)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at DotNetNuke.Security.Permissions.AdvancedPermissionProvider.GenerateVirtualPermissions(List`1 permissions, Int32 portalId, IEnumerable`1 possiblePermissions)
   at DotNetNuke.Security.Permissions.AdvancedPermissionProvider.GenerateVirtualTabPermissions(List`1 permissions, Int32 portalId, Int32 tabId)
   at DotNetNuke.Security.Permissions.AdvancedPermissionProvider.GetTabPermissions(Int32 tabId, Int32 portalId)
   at DotNetNuke.Entities.Tabs.TabInfo.get_TabPermissions()
   at DotNetNuke.Security.Permissions.AdvancedPermissionProvider.CanDoOnPage(TabInfo tab, String exactKey)
   at DotNetNuke.Security.Permissions.AdvancedPermissionProvider.CanViewPage(TabInfo tab)
   at DotNetNuke.UI.Skins.Skin.ProcessMasterModules()
   at DotNetNuke.UI.Skins.Skin.OnInit(EventArgs e)
Expected Behavior

Displaying role names in other languages shouldn't cause 500 errors.

Relevant log output
See stacktrace above.
Anything else?

Workaround: remove Content Editors.Role and Content Managers.Role from the GlobalResources.<culture>.resx files. Those roles then show untranslated, and the keys come back with the next upgrade or language pack.

Affected Versions

10.4.1 (latest release)

What browsers are you seeing the problem on?

No response

Code of Conduct
  • I agree to follow this project's Code of Conduct
Lingua principale
C#
Stelle
1.1k
Fork
791
Merge medio
5g 7h
PR unite (30g)
29

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dnnsoftware/Dnn.Platform

Tutte le issue di dnnsoftware/Dnn.Platform

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.