Bugzilla – Attachment 80410 Details for
Bug 20114
Build better $query_cgi
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Alternative solution
0001-Bug-20114-Use-user-search-parameters-instead-of-recr.patch (text/plain), 8.36 KB, created by
Joonas Kylmälä
on 2018-10-11 13:23:21 UTC
(
hide
)
Description:
Alternative solution
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2018-10-11 13:23:21 UTC
Size:
8.36 KB
patch
obsolete
>From 0e465045830dacb516a2a6d1ed4c05ee1aae23b1 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= <joonas.kylmala@helsinki.fi> >Date: Wed, 10 Oct 2018 14:11:54 +0300 >Subject: [PATCH] Bug 20114: Use user search parameters instead of recreating > them > >This commit replaces the way of calling build_query_compat to recreate >the user submitted search query and instead simply copies the search >query and modifies offset to the correct one. This eliminates bugs >that could happen if build_query_compat() is not up-to-date with the >current range of search parameters available for the user. >--- > catalogue/search.pl | 1 + > koha-tmpl/intranet-tmpl/js/browser.js | 9 +++++---- > .../intranet-tmpl/prog/en/includes/page-numbers.inc | 10 +++++----- > .../intranet-tmpl/prog/en/modules/catalogue/results.tt | 2 +- > 4 files changed, 12 insertions(+), 10 deletions(-) > >diff --git a/catalogue/search.pl b/catalogue/search.pl >index a4e0eb06a8..477b13f819 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -628,6 +628,7 @@ for (my $i=0;$i<@servers;$i++) { > $template->param(limit_cgi_not_only_host_items=> $limit_cgi_not_only_host_items); > $template->param(limit_cgi => $limit_cgi); > $template->param(query_cgi => $query_cgi); >+ $template->param(full_query => $ENV{QUERY_STRING}); > $template->param(query_desc => $query_desc); > $template->param(limit_desc => $limit_desc); > $template->param(offset => $offset); >diff --git a/koha-tmpl/intranet-tmpl/js/browser.js b/koha-tmpl/intranet-tmpl/js/browser.js >index 1557243fc7..59b4527bc1 100644 >--- a/koha-tmpl/intranet-tmpl/js/browser.js >+++ b/koha-tmpl/intranet-tmpl/js/browser.js >@@ -30,15 +30,15 @@ KOHA.browser = function (searchid, biblionumber) { > var browseRecords = function (movement) { > var newSearchPos = me.curPos + movement; > if (newSearchPos > current_search.results.length - 1) { >- window.location = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort=' + current_search.sort + '&gotoPage=detail.pl&gotoNumber=first&searchid=' + me.searchid + '&offset=' + newSearchPos; >+ window.location = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.full_query.replace(/&offset(=[^&]*)?|^offset(=[^&]*)?&?/g, '')) + '&gotoPage=detail.pl&gotoNumber=first&searchid=' + me.searchid + '&offset=' + newSearchPos; > } else if (newSearchPos < 0) { >- window.location = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort=' + current_search.sort + '&gotoPage=detail.pl&gotoNumber=last&searchid=' + me.searchid + '&offset=' + (me.offset - current_search.pagelen); >+ window.location = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.full_query.replace(/&offset(=[^&]*)?|^offset(=[^&]*)?&?/g, '')) + '&gotoPage=detail.pl&gotoNumber=last&searchid=' + me.searchid + '&offset=' + (me.offset - current_search.pagelen); > } else { > window.location = window.location.href.replace('biblionumber=' + biblionumber, 'biblionumber=' + current_search.results[newSearchPos]); > } > } > >- me.create = function (offset, query, limit, sort, newresults, total) { >+ me.create = function (offset, query, limit, sort, newresults, total, full_query) { > if (current_search) { > if (offset === current_search.offset - newresults.length) { > current_search.results = newresults.concat(current_search.results); >@@ -51,6 +51,7 @@ KOHA.browser = function (searchid, biblionumber) { > if (!current_search) { > current_search = { offset: offset, > query: query, >+ full_query: full_query, > limit: limit, > sort: sort, > pagelen: newresults.length, >@@ -89,7 +90,7 @@ KOHA.browser = function (searchid, biblionumber) { > > $(document).ready(function () { > if (me.curPos > -1) { >- var searchURL = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort=' + current_search.sort + '&searchid=' + me.searchid + '&offset=' + me.offset; >+ var searchURL = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.full_query.replace(/&offset(=[^&]*)?|^offset(=[^&]*)?&?/g, '')) + '&offset=' + me.offset; > var prevbutton; > var nextbutton; > if (me.curPos === 0 && current_search.offset === 1) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc >index fd8c8dfc1f..57a71db8e2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc >@@ -1,19 +1,19 @@ > [% IF ( PAGE_NUMBERS ) %]<nav><ul class="pagination"> > [% IF hits_to_paginate < total %]<h6>[% hits_to_paginate %] of [% total %] results loaded, refine your search to view other records</h6>[% END %] > [% IF ( previous_page_offset.defined ) %] >- <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">First</a></li> >+ <li><a href="/cgi-bin/koha/catalogue/search.pl?[% full_query |replace('&offset(=[^&]*)?|^offset(=[^&]*)?&?', '') |html %]">First</a></li> > <!-- Row of numbers corresponding to search result pages --> >- <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% previous_page_offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]"><< Previous</a></li> >+ <li><a href="/cgi-bin/koha/catalogue/search.pl?[% full_query |replace('&offset(=[^&]*)?|^offset(=[^&]*)?&?', '') |html %]&offset=[% previous_page_offset %]"><< Previous</a></li> > [% END %] > [% FOREACH PAGE_NUMBER IN PAGE_NUMBERS %] > [% IF ( PAGE_NUMBER.highlight ) %] > <li class="active"><span>[% PAGE_NUMBER.pg %]</span></li> > [% ELSE %] >- <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% PAGE_NUMBER.offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">[% PAGE_NUMBER.pg %]</a></li> >+ <li><a href="/cgi-bin/koha/catalogue/search.pl?[% full_query |replace('&offset(=[^&]*)?|^offset(=[^&]*)?&?', '') |html %]&offset=[% PAGE_NUMBER.offset %]">[% PAGE_NUMBER.pg %]</a></li> > [% END %] > [% END %] > [% IF ( next_page_offset ) %] >- <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% next_page_offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">Next >></a></li> >- <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %]&offset=[% last_page_offset %][% IF ( sort_by ) %]&sort_by=[% sort_by |url %][% END %]">Last</a></li> >+ <li><a href="/cgi-bin/koha/catalogue/search.pl?[% full_query |replace('&offset(=[^&]*)?|^offset(=[^&]*)?&?', '') |html %]&offset=[% next_page_offset %]">Next >></a></li> >+ <li><a href="/cgi-bin/koha/catalogue/search.pl?[% full_query |replace('&offset(=[^&]*)?|^offset(=[^&]*)?&?', '') |html %]&offset=[% last_page_offset %]">Last</a></li> > [% END %] > </ul></nav>[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index 9a684a1396..1d9964ae29 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -176,7 +176,7 @@ $('#sort_by').change(function() { > ]; > var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10)); > browser.create([% SEARCH_RESULTS.first.result_number %], '[% query_cgi %]', '[% limit_cgi | uri %]','[% sort_cgi | uri %]', >- newresults, '[% total %]'); >+ newresults, '[% total %]', '[% full_query %]'); > [% END %] > [% IF (gotoPage && gotoNumber) %] > [% IF (gotoNumber == 'first') %] >-- >2.17.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20114
:
71089
|
73025
|
80410