[open-ils-commits] [GIT] Evergreen ILS branch master updated. e45c91d53f249b01dce43bf9224b891dfa304942

Evergreen Git git at git.evergreen-ils.org
Thu Apr 28 12:04:43 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  e45c91d53f249b01dce43bf9224b891dfa304942 (commit)
       via  977f85bd0a48cd0954aac40103e7f7ec65da9437 (commit)
      from  b07ef8594437bb7663c1187e8110bba15d161890 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e45c91d53f249b01dce43bf9224b891dfa304942
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Fri Mar 25 16:46:24 2016 -0400

    LP#1562153: fix case where changing sort order to relevance can fail
    
    This patch fixes a cause where sending a 'sort' CGI parameter
    with the empty string as value (which specifies relevance sorting)
    fails to override a previously-set sort order.
    
    To test:
    
    [1] Do a public catalog search starting from the advanced search form,
        e.g., keyword = "cats"
    [2] Change the sort order to (say) Title A-Z from the results page.
    [3] Note that the query string changes to "sort(titlesort) cats" and
        that the results are re-sorted
    [4] Attempt to change the sort order to relevance.
    [5] This time, the sort order does not change ... and it should have.
    [6] Apply the patch and repeat steps 1-5. This time, the sort order
        should be successfully changed.
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
index ecd1bad..51bdf23 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -120,15 +120,18 @@ sub _prepare_biblio_search {
     return () unless $query;
 
     # sort is treated specially, even though it's actually a filter
-    if ($cgi->param('sort')) {
+    if (defined($cgi->param('sort'))) {
         $query =~ s/sort\([^\)]*\)//g;  # override existing sort(). no stacking.
         my ($axis, $desc) = split /\./, $cgi->param('sort');
-        $query = "sort($axis) $query";
+        $query = "sort($axis) $query" if $axis;
         if ($desc and not $query =~ /\#descending/) {
             $query = "#descending $query";
         } elsif (not $desc) {
             $query =~ s/\#descending//;
         }
+        # tidy up
+        $query =~ s/^\s+//;
+        $query =~ s/\s+$//;
     }
 
     my (@naive_query_re, $site);

commit 977f85bd0a48cd0954aac40103e7f7ec65da9437
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Fri Mar 25 16:44:15 2016 -0400

    LP#1562153: add regression test
    
    This patch adds a regression test for successfully
    overrding the sort order in a query from a 'sort' CGI
    parameter.
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/perlmods/t/19-OpenILS-WWW-EGCatLoader.t b/Open-ILS/src/perlmods/t/19-OpenILS-WWW-EGCatLoader.t
index dc57400..9d33829 100644
--- a/Open-ILS/src/perlmods/t/19-OpenILS-WWW-EGCatLoader.t
+++ b/Open-ILS/src/perlmods/t/19-OpenILS-WWW-EGCatLoader.t
@@ -1,6 +1,7 @@
 #!perl -T
 
-use Test::More tests => 6;
+use Test::More tests => 9;
+use CGI;
 
 BEGIN {
 	use_ok( 'OpenILS::WWW::EGCatLoader' );
@@ -10,3 +11,13 @@ use_ok( 'OpenILS::WWW::EGCatLoader::Container' );
 use_ok( 'OpenILS::WWW::EGCatLoader::Record' );
 use_ok( 'OpenILS::WWW::EGCatLoader::Search' );
 use_ok( 'OpenILS::WWW::EGCatLoader::Util' );
+
+my $ctx = {};
+my $cgi = CGI->new();
+$cgi->param('query', 'sort(titlesort) cats site(CONS)');
+$cgi->param('sort',  '');
+$cgi->param('depth', 0);
+my ($new_query, $site, $depth) = OpenILS::WWW::EGCatLoader::_prepare_biblio_search($cgi, $ctx);
+is($site,  'CONS', 'successfully parsed site');
+is($depth, '0',    'successfully parsed depth');
+is($new_query,  'cats site(CONS) depth(0)', 'LP#1562153: change sort order to relevance');

-----------------------------------------------------------------------

Summary of changes:
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm |    7 +++++--
 .../src/perlmods/t/19-OpenILS-WWW-EGCatLoader.t    |   13 ++++++++++++-
 2 files changed, 17 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list