Item14129: MultiSearchPlugin produces strange results with >9 searches

pencil
Priority: Normal
Current State: Confirmed
Released In: n/a
Target Release:
Applies To: Extension
Component: MultiSearchPlugin
Branches:
Reported By: BramVanOosterhout
Waiting For:
Last Change By: GeorgeClark
I'm just passing on bug reported in Support.Question1741 along with possible fix suggested there. Included text from Support.Question1741:
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

-- LynnwoodBrown - 05 Aug 2016

 
Topic revision: r2 - 25 Sep 2016, GeorgeClark
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