• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item6710: Run order issue with SetGetPlugin and DBIQueryPlugin

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Normal New   n/a  

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

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

ItemTemplate
Summary Run order issue with SetGetPlugin and DBIQueryPlugin
ReportedBy TWiki:Main.TaitCyrus
Codebase 5.0.0
SVN Range TWiki-5.1.0-trunk, Tue, 19 Apr 2011, build 21041
AppliesTo Engine
Component

Priority Normal
CurrentState New
WaitingFor

Checkins

TargetRelease n/a
ReleasedIn

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt debug.txt r1 manage 8.6 K 2011-05-03 - 22:35 PeterThoeny  
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r4 - 2011-05-04 - PeterThoeny
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback