TWiki plugins authors have known for a long time that the mechanisms TWiki offers for ordering plugin execution are very basic. A quick review:
- By default, plugins are executed in alphabetical order
- If {PluginsOrder} is defined, the plugins defined therein are executed first, in the order they are declared in {PluginsOrder}. Other plugins are executed in alphabetic order after those from {PluginsOrder}
- A plugin may be added to the {PluginsOrder} order two or more times
- The same order applies to all handlers. So plugins A, B and C are executed in the
beforeEditHandler in the order ABC, and in the afterEditHandler in the same order ABC.
While plugins have remained fairly simple, and the interactions between them low, this has not been a major issue. However with the advent of major content transformations during edits, this has become a much more important issue.
The specific case in question relates to the interaction of the WysiwygPlugin and the SectionalEditContrib+EditContrib. In this case the
beforeEdit processing of the text requires the SectionalEditContrib to break the content into
pre +
text +
post, and present just
text to the editor. Just after that, the pre-processing of the WysiwygPlugin will convert
text to
HTML for editing. Clearly the
afterEditHandler cannot simply replay the same order, otherwise the
TML in
pre and
post will be concatenated to the
HTML before conversion by the WysiwygPlugin. This specific problem can be coded around by restructuring the EditContrib to make correct use of an
afterEditHandler, but the fact remains that the problem is at heart an architectural issue in TWiki, and will bite again in the future.
I'm not sure this problem is isolated to the
beforeEditHandler /
afterEditHandler cycle, but it certainly exists there, and suggests that a more sophisticated mechanism is required for ordering plugin execution.
Some possibilities:
- A simple mechanism, such as a separate {PluginsOrder} for each handler
- A more complex dynamic mechanism, where plugins are able to declare the plugins they must come before/after (dependencies)
See also:
Bugs:Item5828
,
Bugs:Item5858
--
Contributors: CrawfordCurrie - 01 Aug 2008
Discussion