Bug 20763 - AllowPurchaseSuggestionBranchChoice triggers error opac-suggestions.pl is visited without logging in
Summary: AllowPurchaseSuggestionBranchChoice triggers error opac-suggestions.pl is vis...
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Kyle M Hall
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on: 17829
Blocks:
  Show dependency treegraph
 
Reported: 2018-05-14 12:44 UTC by Kyle M Hall
Modified: 2018-06-07 07:18 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 20763: AllowPurchaseSuggestionBranchChoice triggers error opac-suggestions.pl is visited without logging in (2.08 KB, patch)
2018-05-14 12:53 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 20763: AllowPurchaseSuggestionBranchChoice triggers error opac-suggestions.pl is visited without logging in (2.13 KB, patch)
2018-05-25 18:58 UTC, Pierre-Luc Lapointe
Details | Diff | Splinter Review
Bug 20763: AllowPurchaseSuggestionBranchChoice triggers error opac-suggestions.pl is visited without logging in (2.21 KB, patch)
2018-05-28 19:38 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 20763: Remove unecessary Koha::Patron fetch (1.21 KB, patch)
2018-05-28 19:38 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 20763: Remove unecessary Koha::Patron fetch (1.28 KB, patch)
2018-05-29 10:57 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2018-05-14 12:44:39 UTC
Some code executed in the script opac-suggestions.pl if the system preference AllowPurchaseSuggestionBranchChoice is enabled assumes there is a logged in user. If there is not, patrons will see the error "Internal Server Error".
Comment 1 Kyle M Hall 2018-05-14 12:53:22 UTC
Created attachment 75302 [details] [review]
Bug 20763: AllowPurchaseSuggestionBranchChoice triggers error opac-suggestions.pl is visited without logging in

Some code executed in the script opac-suggestions.pl if the system preference AllowPurchaseSuggestionBranchChoice is enabled assumes there is a logged in user. If there is not, patrons will see the error "Internal Server Error".

Test Plan:
1) Enable AllowPurchaseSuggestionBranchChoice
2) Enable AnonSuggestions
3) In the OPAC, perform a search that will have no results,
   click the "Make a purchase suggestion" link.
4) Note the error
5) Apply this patch
6) Reload the page
7) The page should load now!
Comment 2 Pierre-Luc Lapointe 2018-05-25 18:58:47 UTC
Created attachment 75567 [details] [review]
Bug 20763: AllowPurchaseSuggestionBranchChoice triggers error opac-suggestions.pl is visited without logging in

Some code executed in the script opac-suggestions.pl if the system preference AllowPurchaseSuggestionBranchChoice is enabled assumes there is a logged in user. If there is not, patrons will see the error "Internal Server Error".

Test Plan:
1) Enable AllowPurchaseSuggestionBranchChoice
2) Enable AnonSuggestions
3) In the OPAC, perform a search that will have no results,
   click the "Make a purchase suggestion" link.
4) Note the error
5) Apply this patch
6) Reload the page
7) The page should load now!

Signed-off-by: Pierre-Luc Lapointe <pierreluc.lapointe@inLibro.com>
Comment 3 Jonathan Druart 2018-05-28 19:31:06 UTC
One more caused by
  commit 2b90ea2cb0e5e976de7ddef0151ae83d8ac578e6
  Bug 17829: Move GetMember to Koha::Patron
Comment 4 Jonathan Druart 2018-05-28 19:38:15 UTC
Created attachment 75602 [details] [review]
Bug 20763: AllowPurchaseSuggestionBranchChoice triggers error opac-suggestions.pl is visited without logging in

Some code executed in the script opac-suggestions.pl if the system preference AllowPurchaseSuggestionBranchChoice is enabled assumes there is a logged in user. If there is not, patrons will see the error "Internal Server Error".

Test Plan:
1) Enable AllowPurchaseSuggestionBranchChoice
2) Enable AnonSuggestions
3) In the OPAC, perform a search that will have no results,
   click the "Make a purchase suggestion" link.
4) Note the error
5) Apply this patch
6) Reload the page
7) The page should load now!

Signed-off-by: Pierre-Luc Lapointe <pierreluc.lapointe@inLibro.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 5 Jonathan Druart 2018-05-28 19:38:18 UTC
Created attachment 75603 [details] [review]
Bug 20763: Remove unecessary Koha::Patron fetch

If $borrowernumber is not set, there is no userenv.
So let's pick the library code set in the userenv instead of fetching
the Koha::Patron->branchcode from DB

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Jonathan Druart 2018-05-28 19:39:03 UTC
Kyle, I think the conditions can be simplified. Can you confirm I am not missing something with this follow-up?
Comment 7 Kyle M Hall 2018-05-29 10:57:36 UTC
Created attachment 75623 [details] [review]
Bug 20763: Remove unecessary Koha::Patron fetch

If $borrowernumber is not set, there is no userenv.
So let's pick the library code set in the userenv instead of fetching
the Koha::Patron->branchcode from DB

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 8 Jonathan Druart 2018-05-29 14:03:31 UTC
(In reply to Kyle M Hall from comment #7)
> Created attachment 75623 [details] [review] [review]
> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Thanks!
Comment 9 Nick Clemens 2018-06-04 17:49:41 UTC
Pushed to master for 18.11, awesome work everybody!
Comment 10 Martin Renvoize 2018-06-05 11:02:31 UTC
This patch has been pushed to 18.05.x and will be in 18.05.01
Comment 11 Fridolin SOMERS 2018-06-07 07:17:21 UTC
Pushed to 17.11.x for 17.11.07
Comment 12 Fridolin SOMERS 2018-06-07 07:18:41 UTC
Depends on Bug 17829 not in 17.05.x