Implemented: Increase levels of nested search
FormattedSearch supports nesting up to 2 levels. This change allows nesting up to 16 levels. This is needed for complex queries where you have different types of
TWikiForms records and want to pull a field of record, who's topic name is in a field of another record, who's...
Updated doc:
Note: Nested search can be slow, especially if you nest more then 3 times. Nesting is limited to 16 levels. For each new nesting level you need to "escape the escapes", e.g. write
$dollarpercntSEARCH{
for level three,
$dollardollarpercntSEARCH{
for level four, etc.
Change in
twiki/lib/TWiki.pm
:
diff -c bu1 TWiki.pm
*** bu1/TWiki.pm 2004-04-30 14:23:19.000000000 -0700
--- TWiki.pm 2004-07-09 13:41:29.000000000 -0700
***************
*** 2108,2115 ****
$_[0] =~ s/%STOPINCLUDE%//g;
$_[0] =~ s/%SECTION{(.*?)}%//g;
$_[0] =~ s/%ENDSECTION%//g;
! $_[0] =~ s/%SEARCH{(.*?)}%/&handleSearchWeb($1)/ge; # can be nested
! $_[0] =~ s/%SEARCH{(.*?)}%/&handleSearchWeb($1)/ge if( $_[0] =~ /%SEARCH/o );
$_[0] =~ s/%METASEARCH{(.*?)}%/&handleMetaSearch($1)/ge;
}
--- 2108,2117 ----
$_[0] =~ s/%STOPINCLUDE%//g;
$_[0] =~ s/%SECTION{(.*?)}%//g;
$_[0] =~ s/%ENDSECTION%//g;
! my $ok = 16; # SEARCH may be nested up to 16 times
! TRY: while( $_[0] =~ s/%SEARCH{(.*?)}%/&handleSearchWeb($1)/ge ) {
! last TRY unless( --$ok );
! }
$_[0] =~ s/%METASEARCH{(.*?)}%/&handleMetaSearch($1)/ge;
}
Benchmarks
--
PeterThoeny - 09 Jul 2004