From: Jared Camins-Esakov <jcamins@bywatersolutions.com>
To: dev@bywatersolutions.com
Cc: Jared Camins-Esakov <jcamins@bywatersolutions.com>
Subject: [PATCH] Bug 4393: Scan Indexes results cannot be sorted
Date: Sun, 27 Mar 2011 12:49:39 -0400
Message-Id: <1301244579-3715-1-git-send-email-jcamins@bywatersolutions.com>
X-Mailer: git-send-email 1.7.2.3
X-Original-Sender: jcamins@bywatersolutions.com
X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com:
 209.85.216.42 is neither permitted nor denied by best guess record for domain
 of jcamins@bywatersolutions.com) smtp.mail=jcamins@bywatersolutions.com
Precedence: list
Mailing-list: list dev@bywatersolutions.com; contact dev+owners@bywatersolutions.com
List-ID: <dev.bywatersolutions.com>
X-Google-Group-Id: 274270250429
List-Help: <http://www.google.com/support/a/bywatersolutions.com/bin/static.py?hl=en_US&page=groups.cs>,
 <mailto:dev+help@bywatersolutions.com>
Content-Type: text/plain; charset="utf-8"

Because of the way Scan Indexes works, the results cannot be sorted. Previously
when any sort other than relevance (or in some cases popularity) was used, the
search failed. This patch disables sorting on Scan results. This patch also
fixes the index selection dropdown on the results page, which was not being
populated correctly from the Advanced Search screen.
---
 C4/Search.pm        |    2 +-
 catalogue/search.pl |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/C4/Search.pm b/C4/Search.pm
index cd970b7..c17f892 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -391,7 +391,7 @@ sub getRecords {
                 warn "Ignoring unrecognized sort '$sort' requested" if $sort_by;
             }
         }
-        if ($sort_by) {
+        if ($sort_by && !$scan) {
             if ( $results[$i]->sort( "yaz", $sort_by ) < 0 ) {
                 warn "WARNING sort $sort_by failed";
             }
diff --git a/catalogue/search.pl b/catalogue/search.pl
index b22837a..9a8ac25 100755
--- a/catalogue/search.pl
+++ b/catalogue/search.pl
@@ -383,7 +383,7 @@ my @indexes;
 @indexes = split("\0",$params->{'idx'});
 
 # if a simple index (only one)  display the index used in the top search box
-if ($indexes[0] && !$indexes[1]) {
+if ($indexes[0] && (!$indexes[1] || $params->{'scan'})) {
     $template->param("ms_".$indexes[0] => 1);}
 
 
-- 
1.7.2.3