You are here: Foswiki>Tasks Web>Item8849 (10 May 2010, SvenDowideit)Edit Attach

Item8849: trunk SEARCH and FOREACH do one expansion too many in header and footer.

pencil
Priority: Urgent
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Engine
Component:
Branches:
Reported By: SvenDowideit
Waiting For:
Last Change By: SvenDowideit
I think that SEARCH{format="$percentWIKINAME$percent"} might be returning Svendowideit (from Foswiki::Search) rather than %!WIKINAME%

writing unit test - when we formalise the delay expansion operation we will need to make sure we have enough unit tests showing that all macro's that use them don't call Evaluate once too often.

-- SvenDowideit - 06 Apr 2010

or maybe not. it might be that IF isn't as 'good' as i was expecting.

%IF{'$REGISTRATIONGROUPTYPE !="none"' then='$percentINCLUDE{"%WEB%.%TOPIC%" section="extraField_groups" warn="off"}$percent' else='<!-- -->'}%

re written as a simpler eg

%IF{'1' then='$percentINCLUDE{"%WEB%.%TOPIC%" section="extra" warn="on"}$percent' else='false'}%
%STARTSECTION{extra}%<a href="%SCRIPTURL{view}%/%BASEWEB%/%BASETOPIC%">hello there !%TOPIC%, !%BASETOPIC%</a>%ENDSECTION{extra}%

returns: hello there %TOPIC%, %BASETOPIC%

but then when we add more (I'm building the eg until i either debug what i did wrong, or find the bug)

%IF{'1' then='$percentINCLUDE{"%WEB%.%TOPIC%" section="groups" warn="on"}$percent' else='false'}%
%STARTSECTION{groups}%%FOREACH{
    "AaaGroup, AdminGroup"
    header="$percentINCLUDE{$quot%WEB%.%TOPIC%$quot section=$quotextra$quot warn=$quoton$quot}$percent"
    format="$topic"
    separator=", "
}%%ENDSECTION{groups}%

returns:

%FOREACH{ "AaaGroup, AdminGroup" header="$percentINCLUDE{$quotTasks.Item8849$quot section=$quotextra$quot warn=$quoton$quot}$percent" format="$topic" separator=", " }%

adding a STARTINCLUDE which then includes another section which then does the above, which is then used by Sandbox.Item8849.

inculde the form section

the form section

%FOREACH{ "AaaGroup, AdminGroup" header="$percentINCLUDE{$quotTasks.Item8849$quot section=$quotextra$quot warn=$quoton$quot}$percent" format="$topic" separator=", " }%

the form section

%FOREACH{ "AaaGroup, AdminGroup" header="$percentINCLUDE{$quotTasks.Item8849$quot section=$quotextra$quot warn=$quoton$quot}$percent" format="$topic" separator=", " }%


mmm, still not it - I'm afraid its going to require many many levels of INCLUDE - the error on my system is:

<span class='foswikiAlert'>

         Could not perform search. Error was: Use of uninitialized value in concatenation (.) or string at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Macros/INCLUDE.pm line 167.
 at /usr/share/perl/5.10/CGI/Carp.pm line 356
   CGI::Carp::realdie('Use of uninitialized value in concatenation (.) or string at ...') called at /usr/share/perl/5.10/CGI/Carp.pm line 437
   CGI::Carp::die('Use of uninitialized value in concatenation (.) or string at ...') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 145
   Foswiki::__ANON__('Use of uninitialized value in concatenation (.) or string at ...') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Macros/INCLUDE.pm line 167
   Foswiki::INCLUDE('Foswiki=HASH(0x16dbae8)', 'Foswiki::Attrs=HASH(0x2421240)', 'Foswiki::Meta=HASH(0x2420850)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2895
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0x16dbae8)', 'INCLUDE', '"System.DefaultUserRegistration" section="rendergroupheader" ...', 'Foswiki::Meta=HASH(0x2420850)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2789
   Foswiki::_processMacros('Foswiki=HASH(0x16dbae8)', 'System.DefaultUserRegistration %INCLUDE{"System.DefaultUserRe...', 'CODE(0x1628428)', 'Foswiki::Meta=HASH(0x2420850)', 16) called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2587
   Foswiki::innerExpandMacros('Foswiki=HASH(0x16dbae8)', 'SCALAR(0x24157e8)', 'Foswiki::Meta=HASH(0x2420850)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 3059
   Foswiki::expandMacros('Foswiki=HASH(0x16dbae8)', 'System.DefaultUserRegistration %INCLUDE{"System.DefaultUserRe...', 'Foswiki::Meta=HASH(0x2420850)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Meta.pm line 2522
   Foswiki::Meta::expandMacros('Foswiki::Meta=HASH(0x2420850)', 'System.DefaultUserRegistration %INCLUDE{"System.DefaultUserRe...') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Search.pm line 902
   Foswiki::Search::formatResults('Foswiki::Search=HASH(0x22ce570)', undef, 'Foswiki::Search::InfoCache=HASH(0x2420c28)', 'Foswiki::Attrs=HASH(0x22a9bb8)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Macros/FOREACH.pm line 31
   Foswiki::__ANON__() called at /usr/local/share/perl/5.10.1/Error.pm line 415
   eval {...} called at /usr/local/share/perl/5.10.1/Error.pm line 407
   Error::subs::try('CODE(0x22a9be8)', 'HASH(0x2420d78)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Macros/FOREACH.pm line 41
   Foswiki::FOREACH('Foswiki=HASH(0x16dbae8)', 'Foswiki::Attrs=HASH(0x22a9bb8)', 'Foswiki::Meta=HASH(0x228a858)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2895
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0x16dbae8)', 'FOREACH', '\x{a}\x{9}"RegoAgentCanChangeGroup"\x{a}\x{9}header="System.DefaultUserRegist...', 'Foswiki::Meta=HASH(0x228a858)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2789
   Foswiki::_processMacros('Foswiki=HASH(0x16dbae8)', '%FOREACH{\x{a}\x{9}"%GROUPINFO{\x{a}\x{9}\x{9}\x{9}show="allowchange%IF{"$ WIKINAME=\...', 'CODE(0x1628428)', 'Foswiki::Meta=HASH(0x228a858)', 16) called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2587
   Foswiki::innerExpandMacros('Foswiki=HASH(0x16dbae8)', 'SCALAR(0x2275af0)', 'Foswiki::Meta=HASH(0x228a858)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Macros/INCLUDE.pm line 273
   Foswiki::__ANON__() called at /usr/local/share/perl/5.10.1/Error.pm line 415
   eval {...} called at /usr/local/share/perl/5.10.1/Error.pm line 407
   Error::subs::try('CODE(0x2275f58)', 'HASH(0x2257428)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Macros/INCLUDE.pm line 320
   Foswiki::INCLUDE('Foswiki=HASH(0x16dbae8)', 'Foswiki::Attrs=HASH(0x2257920)', 'Foswiki::Meta=HASH(0x1ec38a8)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2895
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0x16dbae8)', 'INCLUDE', '"System.DefaultUserRegistration" section="extraField_groups" ...', 'Foswiki::Meta=HASH(0x1ec38a8)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2789
   Foswiki::_processMacros('Foswiki=HASH(0x16dbae8)', '%INCLUDE{"System.DefaultUserRegistration" section="extraField...', 'CODE(0x1628428)', 'Foswiki::Meta=HASH(0x1ec38a8)', 15) called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2805
   Foswiki::_processMacros('Foswiki=HASH(0x16dbae8)', '<div class="registration">&lt;form name="registration" action="%...', 'CODE(0x1628428)', 'Foswiki::Meta=HASH(0x1ec38a8)', 16) called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2587
   Foswiki::innerExpandMacros('Foswiki=HASH(0x16dbae8)', 'SCALAR(0x2227c00)', 'Foswiki::Meta=HASH(0x1ec38a8)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Macros/INCLUDE.pm line 273
   Foswiki::__ANON__() called at /usr/local/share/perl/5.10.1/Error.pm line 415
   eval {...} called at /usr/local/share/perl/5.10.1/Error.pm line 407
   Error::subs::try('CODE(0x2227528)', 'HASH(0x225e430)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Macros/INCLUDE.pm line 320
   Foswiki::INCLUDE('Foswiki=HASH(0x16dbae8)', 'Foswiki::Attrs=HASH(0x223b6c8)', 'Foswiki::Meta=HASH(0x223c128)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2895
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0x16dbae8)', 'INCLUDE', '"DefaultUserRegistration" section="form" warn="off"', 'Foswiki::Meta=HASH(0x223c128)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2789
   Foswiki::_processMacros('Foswiki=HASH(0x16dbae8)', '\x{a}---+ %MAKETEXT{"Registration"}%\x{a}<!--\x{a}Read genera...', 'CODE(0x1628428)', 'Foswiki::Meta=HASH(0x223c128)', 16) called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2587
   Foswiki::innerExpandMacros('Foswiki=HASH(0x16dbae8)', 'SCALAR(0x1ec4088)', 'Foswiki::Meta=HASH(0x223c128)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Macros/INCLUDE.pm line 273
   Foswiki::__ANON__() called at /usr/local/share/perl/5.10.1/Error.pm line 415
   eval {...} called at /usr/local/share/perl/5.10.1/Error.pm line 407
   Error::subs::try('CODE(0x223c380)', 'HASH(0x2245e20)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Macros/INCLUDE.pm line 320
   Foswiki::INCLUDE('Foswiki=HASH(0x16dbae8)', 'Foswiki::Attrs=HASH(0x2220800)', 'Foswiki::Meta=HASH(0x1b7bee0)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2895
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0x16dbae8)', 'INCLUDE', '"System.DefaultUserRegistration" REGISTRATION_DISABLED=""', 'Foswiki::Meta=HASH(0x1b7bee0)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2789
   Foswiki::_processMacros('Foswiki=HASH(0x16dbae8)', '%INCLUDE{"System.DefaultUserRegistration" REGISTRATION_DISABL...', 'CODE(0x1628428)', 'Foswiki::Meta=HASH(0x1b7bee0)', 15) called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2805
   Foswiki::_processMacros('Foswiki=HASH(0x16dbae8)', '<!--\x{a}      * Set REGISTRATION_DISABLED = %IF{"context registr...', 'CODE(0x1628428)', 'Foswiki::Meta=HASH(0x1b7bee0)', 16) called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 2587
   Foswiki::innerExpandMacros('Foswiki=HASH(0x16dbae8)', 'SCALAR(0x1636480)', 'Foswiki::Meta=HASH(0x1b7bee0)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki.pm line 3059
   Foswiki::expandMacros('Foswiki=HASH(0x16dbae8)', '<!--\x{a}      * Set REGISTRATION_DISABLED = %IF{"context registr...', 'Foswiki::Meta=HASH(0x1b7bee0)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Meta.pm line 2522
   Foswiki::Meta::expandMacros('Foswiki::Meta=HASH(0x1b7bee0)', '<!--\x{a}      * Set REGISTRATION_DISABLED = %IF{"context registr...') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/UI/View.pm line 434
   Foswiki::UI::View::_prepare('<!--\x{a}      * Set REGISTRATION_DISABLED = %IF{"context registr...', 'Foswiki::Meta=HASH(0x1b7bee0)', 0) called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/UI/View.pm line 414
   Foswiki::UI::View::view('Foswiki=HASH(0x16dbae8)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/UI.pm line 303
   Foswiki::UI::__ANON__() called at /usr/local/share/perl/5.10.1/Error.pm line 415
   eval {...} called at /usr/local/share/perl/5.10.1/Error.pm line 407
   Error::subs::try('CODE(0xe93f10)', 'HASH(0x16db6b0)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/UI.pm line 410
   Foswiki::UI::_execute('Foswiki::Request=HASH(0xeb9d38)', 'CODE(0x169d640)', 'view', 1) called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/UI.pm line 270
   Foswiki::UI::handleRequest('Foswiki::Request=HASH(0xeb9d38)') called at /home/sven/src/foswiki/trunk/core/lib/Foswiki/Engine/CGI.pm line 29
   Foswiki::Engine::CGI::run('Foswiki::Engine::CGI=HASH(0x157e8d0)') called at /home/sven/src/foswiki/trunk/core/bin/view line 45.
<p />
</span>

-- SvenDowideit - 06 Apr 2010

turns out the issue is not in the format, but in header and footer.

 

ItemTemplate edit

Summary trunk SEARCH and FOREACH do one expansion too many in header and footer.
ReportedBy SvenDowideit
Codebase trunk
SVN Range
AppliesTo Engine
Component
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:30ebc3bb74de distro:d19e1a319c1d distro:e979fce09566
TargetRelease minor
ReleasedIn 1.1.0
Topic revision: r5 - 10 May 2010, SvenDowideit
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy