Bug 21907

Summary: Error from mainpage when Article requests enabled and either IndependentBranches or IndependentBranchesPatronModifications is enabled
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, katrin.fischer, lucas, martin.renvoize
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 18403    
Bug Blocks:    
Attachments: Bug 21907: Fix article requests count for non-superlibrarians
Bug 21907: Fix article requests count for non-superlibrarians
Bug 21907: Fix article requests count for non-superlibrarians

Description Nick Clemens (kidclamp) 2018-11-28 20:34:59 UTC
DBD::mysql::st execute failed: Column 'branchcode' in where clause is ambiguous [for Statement "SELECT COUNT( * ) FROM `article_requests` `me`  JOIN `borrowers` `borrowernumber` ON `borrowernumber`.`borrowernumber` = `me`.`borrowernumber` WHERE ( ( `branchcode` = ? AND `status` = ? ) )" with ParamValues: 0="LIBRARY", 1='PENDING'] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.
No method count found for Koha::ArticleRequests DBIx::Class::Storage::DBI::_dbh_execute(): Column 'branchcode' in where clause is ambiguous at /usr/share/koha/lib/Koha/Objects.pm line 395
 at /usr/share/koha/intranet/cgi-bin/mainpage.pl line 71.

To recreate:
1 - Enable 'IndependentBranchesPatronModifications' and article requests
2 - Sign in as non-superlibrarian
3 - View plack log
4 - Refresh mainpage, see error in logs
Comment 1 Jonathan Druart 2018-12-11 13:12:12 UTC
Caused by
  commit 710175fbe6721583028083d498f1df4a44bb1784
  Bug 18403: Article requests
Comment 2 Jonathan Druart 2018-12-11 13:14:58 UTC
Created attachment 83037 [details] [review]
Bug 21907: Fix article requests count for non-superlibrarians

The query generates "Column 'branchcode' in where clause is ambiguous"

Test plan:
1 - Enable 'IndependentBranchesPatronModifications' and article requests
2 - Sign in as non-superlibrarian
3 - View plack log
4 - Refresh mainpage, see error in logs
Comment 3 Nick Clemens (kidclamp) 2019-01-11 14:29:17 UTC
Created attachment 83794 [details] [review]
Bug 21907: Fix article requests count for non-superlibrarians

The query generates "Column 'branchcode' in where clause is ambiguous"

Test plan:
1 - Enable 'IndependentBranchesPatronModifications' and article requests
2 - Sign in as non-superlibrarian
3 - View plack log
4 - Refresh mainpage, see error in logs

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 4 Katrin Fischer 2019-02-03 10:54:25 UTC
I am not even sure if the current behaviour is correct: When requesting an article the pick-up branch is selected and it seems only libraries from the pick-up branch see the request... so the fact where the item actually is is not taken into account at all and libraries who might be able to fill the request are not notified?
Comment 5 Katrin Fischer 2019-02-03 11:17:23 UTC
My confusion was related to bug 22265. PQA.
Comment 6 Katrin Fischer 2019-02-03 11:18:37 UTC
Created attachment 84681 [details] [review]
Bug 21907: Fix article requests count for non-superlibrarians

The query generates "Column 'branchcode' in where clause is ambiguous"

Test plan:
1 - Enable 'IndependentBranchesPatronModifications' and article requests
2 - Sign in as non-superlibrarian
3 - View plack log
4 - Refresh mainpage, see error in logs

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 7 Nick Clemens (kidclamp) 2019-02-04 17:46:04 UTC
Awesome work all!

Pushed to master for 19.05
Comment 8 Martin Renvoize 2019-02-11 13:42:47 UTC
Pushed to 18.11.x for 18.11.03
Comment 9 Lucas Gass 2019-02-12 21:05:09 UTC
backported to 18.05.x for 18.05.09
Comment 10 Fridolin Somers 2019-02-15 06:47:40 UTC
Depends on Bug 18403 not in 17.11.x