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.