Bug 10217 - Make sure direct links to detail views work when there is no session
Summary: Make sure direct links to detail views work when there is no session
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low critical
Assignee: Magnus Enger
QA Contact:
URL:
Keywords:
: 10175 (view as bug list)
Depends on: 7740
Blocks: 8198
  Show dependency treegraph
 
Reported: 2013-05-08 09:56 UTC by Magnus Enger
Modified: 2019-06-27 09:24 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 10217 - Make sure direct links to detail views work when there is no session (1.39 KB, patch)
2013-05-08 10:07 UTC, Magnus Enger
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10217 - Make sure direct links to detail views work when there is no session (1.49 KB, patch)
2013-05-08 20:11 UTC, Owen Leonard
Details | Diff | Splinter Review
[PASSED QA] Bug 10217 - Make sure direct links to detail views work when there is no session (1.60 KB, patch)
2013-05-11 14:35 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2013-05-08 09:56:50 UTC
On current master, if you do not have a session and try to visit a detail view page you will get an error:

Can't use an undefined value as a HASH reference at /home/magnus/scripts/kohadev/opac/opac-detail.pl line 445.

The offending line looks like this:

my $branch = C4::Context->userenv->{branch};

This will typically happen if you follow a direct link to a detail view in an OPAC you have not visited before, or not visited in such a long time that the session expired. 

If you get the error, visit the front page and go back to the detail view that gave the error it will work, because visiting the front page establishes a new session:

<rangi> you dont have a userenv
<rangi> if you arent logged in
<magnuse> that makes sense :-) 
<magnuse> but... do you get one by visiting the front page, then? 
<rangi> yep
<rangi> starts an anonymous session
<magnuse> and that only happens on the front page? 
<rangi> or search results
<rangi> doesnt happen on detail page
<rangi> and it shouldnt
<rangi> cos else google would spawn a zillion sessions

Huge thanks to Chris C. who suggested the fix for this, but did not want to submit a patch for it. :-) 

The problem was caused by Bug 7740. There was a similar problem in opac-serach.pl, fixed on Bug 9980.
Comment 1 Magnus Enger 2013-05-08 10:07:53 UTC Comment hidden (obsolete)
Comment 2 Owen Leonard 2013-05-08 20:11:59 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2013-05-11 14:35:52 UTC
Created attachment 18085 [details] [review]
[PASSED QA] Bug 10217 - Make sure direct links to detail views work when there is no session

To reproduce:
- Make sure you do not have a session for the OPAC you will be testing
  with. Delete the CGISESSID session cookie if you have one.
- Go directly to a detail view, e.g.:
  /cgi-bin/koha/opac-detail.pl?biblionumber=1
- Observe the error "Can't use an undefined value as a HASH
  reference at /home/magnus/scripts/kohadev/opac/opac-detail.pl line 445."

To test:
- Apply the patch
- Reload the page with the error
- You should now see the detail view of the record, as usual

Thanks to Chris Cormack who suggested the fix for this!

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Tested according to test plan, confirmed patch fixes the problem.
All tests and QA script pass.
Comment 4 Jared Camins-Esakov 2013-05-12 13:46:33 UTC
This patch has been pushed to master and 3.12.x.
Comment 5 Julian Maurice 2013-05-13 07:21:34 UTC
*** Bug 10175 has been marked as a duplicate of this bug. ***
Comment 6 Chris Cormack 2013-05-13 09:28:38 UTC
Not needed for 3.10.x or below