| When the parameters of a wiki UI extension contain a script (Velocity or a localization shortcut) and they are requested in a context where there is no current wiki (for example from a thread where no XWiki context has been initialized), WikiUIExtensionParameters#get() fails with a NullPointerException instead of returning the parameters. The cause is that the current wiki used as the key of the evaluated parameters cache is computed with modelContext.getCurrentEntityReference().extractReference(EntityType.WIKI).getName(), and ModelContext#getCurrentEntityReference() returns null when there is no execution context, no XWiki context, or no wiki set in it. The code dates from XWIKI-8845. It was reported by SonarCloud (rule javabugs:S2259) after XWIKI-25421 re-wrapped the line, which made it count as new code and turned the master quality gate red. Expected The parameters are evaluated as usual and cached for "no current wiki", and they are evaluated again once a wiki is set in the context. |