[Bug 43540] New: Switching OPAC language loses /bib/<id> short URLs, redirects to homepage
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Bug ID: 43540 Summary: Switching OPAC language loses /bib/<id> short URLs, redirects to homepage Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: OPAC Assignee: oleonard@myacpl.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Target Milestone: --- When switching the OPAC interface language on a page reached via Koha's own /bib/<biblionumber> short URL (see the RewriteRule shipped in apache-shared-opac.conf / etc/koha-httpd.conf), the user is redirected to the OPAC homepage instead of staying on the record they were viewing. The same applies on the staff side for /bib/<biblionumber> against catalogue/detail.pl. Root cause: the /bib/ RewriteRule uses the [PT] flag, meaning it is an internal rewrite - the browser's address bar and Referer header keep showing /bib/<id>, never /cgi-bin/koha/opac-detail.pl. Koha::Util::Navigation::local_referer() (used by opac-changelanguage.pl and changelanguage.pl to work out where to send the user back to after a language switch) treats a referer as local only if it matches the site's OPACBaseURL/staffClientBaseURL AND contains the literal substring /cgi-bin/koha/. Since /bib/<id> never contains that substring, local_referer() falls through to its fallback (the site root), so the language switch drops the user on the homepage. This patch extends local_referer()'s recognized local-path pattern to also accept Koha's own /bib/<digits> short URL, in both the OPACBaseURL/staffClientBaseURL branch and the no-base-URL fallback branch. Test plan: 1. Enable mod_rewrite and confirm the /bib/<biblionumber> short URL works for an OPAC record (e.g. /bib/123 loads the same page as opac-detail.pl?biblionumber=123). 2. On that page, switch OPAC language using the language selector in the header or footer. 3. Before this patch: you are redirected to the OPAC homepage, losing the record. 4. After this patch: you are redirected back to /bib/123, now in the newly selected language. 5. prove t/Koha/Util/Navigation.t - all tests pass, including two new /bib/ short url cases. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 205886 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205886&action=edit Bug 43540: Recognize /bib/ short URL as local in local_referer Koha ships an Apache RewriteRule for /bib/<biblionumber> short URLs (apache-shared-opac.conf, apache-shared-intranet.conf, koha-httpd.conf) using the [PT] flag, so the rewrite happens internally - the browser's Referer header keeps showing /bib/<id>, never /cgi-bin/koha/.... Koha::Util::Navigation::local_referer(), used by opac-changelanguage.pl and changelanguage.pl to redirect back to the referring page after a language switch, only recognized a referer as local if it matched the site's base URL AND contained the literal substring /cgi-bin/koha/. Since /bib/<id> never contains that substring, the language switch fell back to the site root, dropping the user on the homepage instead of returning them to the record they were viewing. This patch extends local_referer()'s recognized local-path pattern to also accept /bib/<digits>, in both the base-URL branch and the no-base-URL fallback branch. Test plan: 1. Enable mod_rewrite and confirm /bib/<biblionumber> loads the same page as opac-detail.pl?biblionumber=<biblionumber>. 2. On that page, switch OPAC language via the language selector. 3. Before this patch: redirected to the OPAC homepage. 4. After this patch: redirected back to /bib/<biblionumber>. 5. prove t/Koha/Util/Navigation.t - all tests pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=23201 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |21299 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21299 [Bug 21299] Move referer code from changelanguage to module in opac and staff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|oleonard@myacpl.org |martin.renvoize@openfifth.c | |o.uk -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 205887 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205887&action=edit Bug 43540: Recognize core-shipped short urls as local in local_referer Koha ships Apache rewrites/aliases for several "short" or friendly OPAC and staff URLs (apache-shared-opac.conf, apache-shared-intranet.conf, koha-httpd.conf): /bib/<biblionumber> - single record, rewritten internally [PT] /isbn/<isbn>, /issn/<issn> - rewritten internally [PT] to /search?q=... /search - ScriptAlias'd straight to opac-search.pl / catalogue/search.pl None of these ever appear as /cgi-bin/koha/... in the browser's Referer header: the [PT] rewrites happen internally (the browser keeps showing the original short URL), and /search is aliased to a script outside /cgi-bin/koha/ altogether. Koha::Util::Navigation::local_referer(), used by opac-changelanguage.pl and changelanguage.pl to redirect back to the referring page after a language switch, only recognized a referer as local if it matched the site's base URL AND contained the literal substring /cgi-bin/koha/. Since none of the above contain that substring, the language switch fell back to the site root, dropping the user on the homepage instead of returning them to the record or search they were viewing. This patch extends local_referer()'s recognized local-path pattern to also accept /bib/<digits>, /isbn/<isbn>, /issn/<issn> and /search, in both the base-URL branch and the no-base-URL fallback branch. Test plan: 1. Enable mod_rewrite and confirm /bib/<biblionumber>, /isbn/<isbn> and /issn/<issn> all load the expected OPAC page. 2. On each of those pages, switch OPAC language via the language selector. 3. Before this patch: redirected to the OPAC homepage. 4. After this patch: redirected back to the same short URL. 5. prove t/Koha/Util/Navigation.t - all tests pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #205886|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #205887|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 205888 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205888&action=edit Bug 43540: Recognize core-shipped short urls as local in local_referer Koha ships Apache rewrites/aliases for several "short" or friendly OPAC and staff URLs (apache-shared-opac.conf, apache-shared-intranet.conf, koha-httpd.conf): /bib/<biblionumber> - single record, rewritten internally [PT] /isbn/<isbn>, /issn/<issn> - rewritten internally [PT] to /search?q=... /search - ScriptAlias'd straight to opac-search.pl / catalogue/search.pl None of these ever appear as /cgi-bin/koha/... in the browser's Referer header: the [PT] rewrites happen internally (the browser keeps showing the original short URL), and /search is aliased to a script outside /cgi-bin/koha/ altogether. Koha::Util::Navigation::local_referer(), used by opac-changelanguage.pl and changelanguage.pl to redirect back to the referring page after a language switch, only recognized a referer as local if it matched the site's base URL AND contained the literal substring /cgi-bin/koha/. Since none of the above contain that substring, the language switch fell back to the site root, dropping the user on the homepage instead of returning them to the record or search they were viewing. This patch extends local_referer()'s recognized local-path pattern to also accept /bib/<digits>, /isbn/<isbn>, /issn/<issn> and /search, in both the base-URL branch and the no-base-URL fallback branch. Test plan: 1. Enable mod_rewrite and confirm /bib/<biblionumber>, /isbn/<isbn> and /issn/<issn> all load the expected OPAC page. 2. On each of those pages, switch OPAC language via the language selector. 3. Before this patch: redirected to the OPAC homepage. 4. After this patch: redirected back to the same short URL. 5. prove t/Koha/Util/Navigation.t - all tests pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org