cross
New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists
This question about Using an extension: Task filed

Suggested fix to MultiSearchPlugin

Hi, I tried to use MultiSearchPlugin with >9 searches. I got strange results from 10 upward.

After looking at the code I thought the problem was in:
   for ( my $i = 1 ; $i <= $searchCounter ; $i++ ) {
       $header =~ s/\$ntopics$i/$totalFound[$i]/gs;
       $footer =~ s/\$ntopics$i/$totalFound[$i]/gs;
   }

For $i = 1 ntopiics1 will be updated, but so will $ntopics10, $ntopics11 and so on.

To avoid the issue I have on my machine reversed the loop. From:
  • for ( my $i = 1 ; $i <= $searchCounter ; $i++ ) {
To:
  • for ( my $i = $searchCounter ; $i >= 1 ; $i-- ) {
It now reads:
   for ( my $i = $searchCounter ; $i >= 1 ; $i-- ) {
       $header =~ s/\$ntopics$i/$totalFound[$i]/gs;
       $footer =~ s/\$ntopics$i/$totalFound[$i]/gs;
   }

So now $ntopics100 is replaced before $ntopics19 ... $ntopics10 before $ntopics1. This change has the desired result. But since I do not fully understand the implementation of MULTISEARCH I am not sure of the impact on the interval implementation (I think I have left that alone) and possible side effects in the index implementation.

A diff between original and update follows:
$ diff MultiSearchPlugin.pm.ORIGINAL MultiSearchPlugin.pm.UPDATED
408c408,409
<             for ( my $i = 1 ; $i <= $searchCounter ; $i++ ) {
---
> ## BvO        for ( my $i = 1 ; $i <= $searchCounter ; $i++ ) {
>               for ( my $i = $searchCounter ; $i >= 1 ; $i-- ) {
458c459,460
<         for ( my $i = 1 ; $i <= $searchCounter ; $i++ ) {
---
>         for ( my $i = $searchCounter ; $i >= 1 ; $i-- ) {
> ## BvO  for ( my $i = 1 ; $i <= $searchCounter ; $i++ ) {
547c549,550
<     for ( my $i = 1 ; $i <= $searchCounter ; $i++ ) {
---
>     for ( my $i = $searchCounter ; $i >= 1 ; $i-- ) {
> ## BvO for ( my $i = 1 ; $i <= $searchCounter ; $i++ ) {

Hope this helps to improve MULTISEARCH.

regards....

-- BramVanOosterhout - 03 Jan 2016

Filed as task: Tasks.Item14129

-- Main.LynnwoodBrown - 05 Aug 2016 - 16:57

 

QuestionForm edit

Subject Using an extension
Extension MultiSearchPlugin
Version Foswiki 2.0.3
Status Task filed
Related Topics Tasks.Item14129
Topic revision: r2 - 05 Aug 2016, LynnwoodBrown - This page was cached on 22 Jun 2018 - 17:19.

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