Problem When several pages define a wiki macro with the same id and the same visibility (e.g. a page holding a wiki macro copied as a template, then modified), the last registered one overwrites the others. Deleting the page of the winning macro, or removing its macro object, then leaves no macro at all ("Unknown macro") even though other pages still define it, until the wiki is restarted. Expected With XCOMMONS-85, the component manager keeps all the components registered with the same role and hint: the one with the best priority is used (the last registered one in case of same priority) and the other ones are hidden until it's unregistered. Wiki macros should benefit from it: removing the macro of one page should make the macro defined in another page with the same id available again. What needs to change in DefaultWikiMacroManager
- Unregister the macro by its descriptor and instance (ComponentManager#unregisterComponent(ComponentDescriptor, Object), new in XCOMMONS-85) instead of by role type and hint, which removes all the macros registered with that id, including the ones of other pages.
- Unregister the previous macro of the same document (known from wikiMacroMap) before registering it again. Wiki macros are registered again without being unregistered first, e.g. for all the wiki macros on each XAR import (RegisterMacrosOnImportListener). With stacking, each of these registrations would otherwise keep the previous instance hidden in the component manager.
Both changes have to go together, and have to be released with XCOMMONS-85. |