[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.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #205888|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 #4 from Owen Leonard <oleonard@myacpl.org> --- Created attachment 207397 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207397&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> Signed-off-by: Owen Leonard <oleonard@myacpl.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |bibliothek@th-wildau.de |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Jan Kissig <bibliothek@th-wildau.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Jan Kissig <bibliothek@th-wildau.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #207397|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 #5 from Jan Kissig <bibliothek@th-wildau.de> --- Created attachment 208216 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208216&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> Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Jan Kissig <bibliothek@th-wildau.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 --- Comment #6 from Jan Kissig <bibliothek@th-wildau.de> --- Created attachment 208217 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208217&action=edit Bug 43540: (QA follow-up) Add opac-search.pl to regex This adds the opac-search.pl to the regex which used to check if the referer is local. Both /search and the hereby introduced /opac-search.pl are set as a ScriptAlias in apache-shared-opac.conf. To test: a) follow the test plan for the main patch and additionally: b) go to /opac-search.pl and perform a search and change the language c) without patch you will be redirected to opac home, with patch applied you will be redirected to the correct referring page. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 --- Comment #7 from Jan Kissig <bibliothek@th-wildau.de> --- As for the mentioned /bib, /isbn, /issn and /search paths the patch worked fine. Added the missing ScriptAlias /opac-search.pl to the regex. Remark one testing: When using ktd with --proxy I had to set the OPACBaseURL and staffClientBaseURL according to the instance name: f.e. when using main as instance name: OPACBaseURL = http://main.localhost/ staffClientBaseURL = http://main-intra.localhost -- 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 ---------------------------------------------------------------------------- Version(s)| |26.11.00 released in| | --- Comment #8 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Pushed to main for 26.11 with consent from Pedro whilst he's on annual leave -- 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|Passed QA |Pushed to main -- 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=43444 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|26.11.00 |26.11.00,26.05.06 released in| | Status|Pushed to main |Pushed to stable -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43540 --- Comment #9 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Nice work everyone! Pushed to 26.05.x for the upcoming 26.05.06 release. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org