I've a page that uses %SET{}% to set a variable (based on a passed in parameter) and this variable then needs to be used inside of a %DBI_QUERY%, and specificially the main SQL query, but the %GET% inside of the SQL evaluates to nothing. So in the SQL function
get_stat_values2
the 2nd parameter evaluates to nothing even though the %GET% immediately following the %SET% shows the correct value. Also, the %GET% inside of the
.header
line DOES show the correct value. My configuration is set such that the
PluginsOrder is set to:
$TWiki::cfg{PluginsOrder} = 'SetGetPlugin,
SpreadSheetPlugin,
DBIQueryPlugin,
DatabasePlugin,
ChartPlugin';
which says that
SetGetPlugin should run before any of the database plugins.
My page roughly looks like:
%SET{"PER_SERVER_QUEUE" value="%IF{"'%URLPARAM{OS}%'='HP-UX'" then="GBL_PRI_QUEUE" else="GBL_RUN_QUEUE" }%"}%
PER_SERVER_QUEUE = '%GET{PER_SERVER_QUEUE}%'
%TABLE{initsort="2"}%
%DBI_QUERY{"performance"}%
SELECT
*
FROM
get_stat_values2('GBL_CPU_TOTAL_UTIL', '%GET{PER_SERVER_QUEUE}%', '%URLPARAM{SERVER}%', %URLPARAM{MONTHS}%)
.header
%TABLE{initsort="2" headerrows="2"}%\n
| * * | * * | *CPU Util* |||| *%GET{"PER_SERVER_QUEUE"}%* ||||\n
| *Server* | *Date* | *50th %ile* | *Monthly Avg* | *5th %ile* | *95th %ile* | *50th %ile* | *Monthly Avg* | *5th %ile* | *95th %ile* |\n
.body
| %server_name% | %date% | %a_percentile50% | %a_monthly_mean% | %a_percentile05% | %a_percentile95% | %b_percentile50% | %b_monthly_mean% | %b_percentile05% | %b_percentile95% | \n
%DBI_QUERY%
When I turn on $debug in both
DBIQueryPlugin and
SetGetPlugin and then look at the debug.txt file (which I'll attach below), I do see initialization of
SetGetPlugin done before
DBIQueryPlugin. From looking at the debug.txt file it appears that the
DBIQueryPlugin API commonTagsHandler() is being called before the
SetGetPlugin TWiki::Func::registerTagHandler API.
DBIQueryPlugin then tries to render the %GET%, but since
SetGetPlugin hasn't been called yet on the entire topic page the %SET% hasn't been done yet, so
SetGetPlugin renders the %GET% as empty.
--
TWiki:Main/TaitCyrus
- 2011-05-03
I attached the debug.txt file Tait sent via e-mail.
--
TWiki:Main.PeterThoeny
- 2011-05-03
The reason why it does not work: Only the
SetGetPlugin uses the registerTagHandler in init. The
DBIQueryPlugin handles its variables in beforeCommonTagsHandler and commonTagsHandler, which causes the out of sync eval order.
You can contact the maintainer of the
DBIQueryPlugin to see if it is OK to change the plugin to use registerTagHandler instead.
--
TWiki:Main.PeterThoeny
- 2011-05-03
This is either a bug in the core TWiki because regardless of whether a plugin is using the old API or the new API, it should still follow the order specified in
PluginsOrder or this is a bug in
configure
in that it is missing a
note describing this situation that
PluginsOrder only applies to plugins using the the same plugin API, but when there are plugins using a mix of old and new API
PluginsOrder does not apply.
--
TaitCyrus - 2011-05-04
Well, it is a bit more complicated than that. The plugins order
is followed properly, but depending on what callbacks plugins use you get different results. Even with the older API, if plugin A runs before plugin B, and A uses commonTagsHandler and B uses beforeCommonTagsHandler, variables of B are expanded before variables of A.
Variables of plugins that use registerTagHandler are expanded as expected, regardless if they enclose / are surrounded by core variables, preferences settings, session variables and other plugin variables: All variables get expanded inside out, left to right. Plugins that use any ...commonTagsHandler are on their own, e.g. they bypass the inside-out/left-right eval order.
Feel free to update the core docs and configure's TWiki.spec.
--
TWiki:Main.PeterThoeny
- 2011-05-04