Details
-
Bug
-
Resolution: Fixed
-
Major
-
11.10
-
Unknown
-
N/A
-
N/A
-
Description
When the Distribution Wizard runs on a sub-wiki, its "Orphan dependencies" step can list, as orphaned, extensions that are installed on the root namespace (farm level) and are still needed. Uninstalling one of them from that step also uninstalls, on the sub-wiki, every extension that depends on it (the flavor included), and all the pages of those extensions get deleted.
This is what happened in XWIKI-25633: Attachment Picker Macro 17.10.14 (or PDF Export default API implementation 17.10.14 on a second try) was listed next to a real orphan (Ratings Application 16.10.5), and uninstalling it removed Attachment Picker Application, XWiki Standard Common Application, XWiki Standard Flavor for sub-wikis and a custom flavor from the sub-wiki, with all their pages (Main.WebHome, etc.).
Cause
The list displayed by the step is computed in templates/distribution/extension.clean.wiki, not by CleanExtensionsDistributionStep:
#foreach ($installedExtension in $services.extension.installed.getInstalledExtensions($currentNamespace)) #if ($installedExtension.isDependency($currentNamespace)) #if ($installedExtension.isInstalled($NULL)) #if ($xcontext.isMainWiki()) #set($orphanedExtension = $services.extension.installed.repository.getBackwardDependencies($installedExtension.id, true).isEmpty()) #end #else #set($orphanedExtension = $services.extension.installed.repository.getBackwardDependencies($installedExtension.id.id, $currentNamespace, true).isEmpty()) #end #if ($orphanedExtension) #set ($void = $orphanedExtensions.add($installedExtension)) #end #end #end
$orphanedExtension is never reset between iterations. On a sub-wiki, an extension installed on root as a dependency does not set it (root extensions are only meant to be checked from the main wiki), so it inherits the result of the previous extension of the loop. As soon as a real orphan is found, the root dependencies which come after it in the (hash based) iteration order are listed too. This explains why:
- it only happens on a sub-wiki
- the wrongly listed extensions are installed on root (here JARs)
- the list is not stable from one execution to another
- the step is displayed at all only when there is a real orphan: CleanExtensionsDistributionStep#prepare(), which decides whether to display it, implements the same logic correctly
Proposed fix
Move the computation of the orphaned extensions to Java, so that the step (prepare()) and the template share the same implementation, and make the template use it through the internal distribution script service.
Attachments
Issue Links
- is related to
-
XWIKI-25811 XarInstalledExtensionRepository#getBackwardDependencies returns null instead of an empty collection for non-XAR extensions
-
- Closed
-
- relates to
-
XWIKI-25633 Distribution Wizard "Orphan dependencies" step ends with an error and deletes flavor pages when upgrading a sub-wiki from 16.10.5 to 17.10.14
-
- Closed
-
-
XWIKI-16823 Distribution Wizard should propose to uninstall invalid extension which are no longer needed
-
- Closed
-