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...
Created attachment 29464 [details] [review] 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.
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.)
*** Bug 8466 has been marked as a duplicate of this bug. ***
Created attachment 29590 [details] [review] [SIGNED-OFF] 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.
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>
Patch pushed to master. Thanks David!