Implemented: New beforeCommonTagsHandler and afterCommonTagsHandler Plugin Callbacks
There is already a
CommonTagsHandler callback, which is used by Plugins to expand Plugin specific
%VARIABLES%
. The
TWiki::handleCommonTags
function is expanding preferences variables and internal variables before calling the Plugin callback handler.
Rendering topics that have lots of dynamic content can be slow. It is especially slow for nested
FormattedSearch. A Plugin that caches topic text with the variables expanded can speed up the page rendering considerably, at the cost of not showing up-to-date content.
Unfortunately it is not possible to use the existing
commonTagsHandler
callback since preferences variables and internal variables are already expanded. For this, new
beforeCommonTagsHandler
and
afterCommonTagsHandler
are needed that gets called at the beginning and at the end of the
TWiki::handleCommonTags
.
Sequence of variable expansion
Internally,
TWiki::handleCommonTags
expands all variables in the following sequence:
- call
beforeCommonTagsHandler
of all Plugins ( new )
- take out verbatim tags
- handle all preferences variables
- handle all internal variables (
%WEB%
, %SEARCH{}%
etc)
- handle
%INCLUDE{}%
; for each include:
- take out verbatim tags
- handle all preferences variables
- handle all internal variables (
%WEB%
etc)
- call
commonTagsHandler
of all Plugins
- handle all preferences variables (again because of Plugins)
- handle all internal variables (again because of Plugins)
- recursive call to handle
%INCLUDE{}%
- call commonTagsHandler of all Plugins
- handle all preferences variables (again because of Plugins)
- handle all internal variables (again because of Plugins)
- handle
%TOC{}%
- put back verbatim tags
- call
afterCommonTagsHandler
of all Plugins ( new )
Contributors:
--
PeterThoeny,
ThomasWeigert - 13 Jul 2004
Discussions
Related,
StepByStepRenderingOrder is documenting the rendering sequence but it is not yet accurate.
--
PeterThoeny - 13 Jul 2004
While this is off-topic, the above sequence (I modified the wording to make clear where the recursive call for handling
%INCLUDE{}%
is) made me wonder: why is
%INCLUDE{}%
handled in the middle at the outer level, but then at the tail of each recursive call to
TWiki::handleIncludeFile
?
--
ThomasWeigert - 14 Jul 2004
Reason: The topic name to INCLUDE may contain preferences and/or internal variables like
%INCLUDE{"%TOPIC%SideBar"}%
. The INCLUDEd text may contain preferences and/or internal variables like
%TOPIC%
and
%INCLUDINGTOPIC%
that need to be resolved correctly before the Plugins hook is called. The Plugins might introduce new variables that need to be resolved before recursion (the included text could contain
%INCLUDE{"%TOPIC%SideBar"}%
)
--
PeterThoeny - 15 Jul 2004
This enhancement is now in
SVN.
FYI, I had a disk space issue that resulted in a failed notify. The issue is resolved, but twiki-dev did not get the change log.
1 *
diffs.txt: Diffs (for reference, not for patch)
--
PeterThoeny - 15 Jul 2004
Benchmark tests (msec)
--
PeterThoeny - 16 Jul 2004