Bug 12522 - Fatal database error when viewing Holds for Bib with no Items
Summary: Fatal database error when viewing Holds for Bib with no Items
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Hold requests (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
: 8466 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-07-03 06:30 UTC by David Cook
Modified: 2015-06-04 23:32 UTC (History)
4 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:


Attachments
Bug 12522 - Fatal database error when viewing Holds for Bib with no Items (2.50 KB, patch)
2014-07-03 06:42 UTC, David Cook
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 12522 - Fatal database error when viewing Holds for Bib with no Items (2.65 KB, patch)
2014-07-09 16:18 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[PASSED QA] Bug 12522 - Fatal database error when viewing Holds for Bib with no Items (2.70 KB, patch)
2014-07-11 12:39 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 David Cook 2014-07-03 06:30:32 UTC
Currently, if you have the environmental variable set (via "SetEnv DEBUG 1"), you can trigger a fatal database error in the staff client by clicking "Holds" on a bib record if it has no items attached.

If you don't have DEBUG set, you'll get database error warning messages in your logs but it won't be enough to bring down Koha. 

I doubt many people are running in production with DEBUG turned on, and I doubt that many people try to view the Holds tab on a bib record that doesn't have any items.

That said, it's a good idea to reduce errors and warnings...
Comment 1 David Cook 2014-07-03 06:42:28 UTC Comment hidden (obsolete)
Comment 2 David Cook 2014-07-03 06:46:45 UTC
I suppose I should note that "Koha::get_infos_of" should probably be removed, and  "C4::Items::GetItemInfosOf", and "C4::Biblio::GetBiblioItemInfosOf" should be refactored.

(I should have probably included some explanatory comments in my patch as well, but...oh well.)
Comment 3 Owen Leonard 2014-07-03 12:36:40 UTC
*** Bug 8466 has been marked as a duplicate of this bug. ***
Comment 4 Bernardo Gonzalez Kriegel 2014-07-09 16:18:09 UTC Comment hidden (obsolete)
Comment 5 Kyle M Hall 2014-07-11 12:39:45 UTC
Created attachment 29632 [details] [review]
[PASSED QA] Bug 12522 - Fatal database error when viewing Holds for Bib with no Items

This patch fixes some potential SQL syntax errors, which can cause
fatal software errors in Koha when the environmental variable DEBUG
is on.

_TEST PLAN_

Before applying:

0) Ensure that you don't have "SetEnv DEBUG 1" in your Apache config
1) Create a new bib record
2) Click on the "Holds" tab before creating any items
3) Note the message "Cannot place hold: this record has no
items attached."

4) Add "SetEnv DEBUG 1" to your Apache config
5) Restart Apache
6) Refresh your page
7) Note the following Software Error: "DBD::mysql::st execute failed:
You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to
use near ')' at line 3 at /koha/lib/C4/Koha.pm line 835.

8) Apply the patch

9) Refresh your page
10) Note the message from Step 3

Thorough tester:

11) Remove "SetEnv DEBUG 1" from your Apache config, restart Apache,
and refresh your page. You should see the message from Step 3.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Error reproduced, patch fixes it.
Tested following test plan, no koha-qa errors.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 6 Tomás Cohen Arazi 2014-07-14 12:03:16 UTC
Patch pushed to master.

Thanks David!