Bug 6579 - getalert SQL invalid for KOHA_USER
Summary: getalert SQL invalid for KOHA_USER
Status: CLOSED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: Notices (show other bugs)
Version: rel_3_0
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact: Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-12 04:00 UTC by Joe Atzberger
Modified: 2015-12-03 22:00 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joe Atzberger 2011-07-12 04:00:32 UTC
The code for getalert in C4::Letters fails to account for one important case.  While the POD says "all parameters NON mandatory", the result of NO arguments produces invalid SQL. 

The errors in the log look like:

[error] [client 71.64.0.171] [Mon Jul 11 19:54:12 2011] opac-user.pl: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at /usr/share/koha/lib/C4/Letters.pm line 197, <DATA> line 522., referer: https://my.koha.edu/cgi-bin/koha/opac-user.pl

[error] [client 71.64.0.171] [Mon Jul 11 19:54:12 2011] opac-user.pl: DBD::mysql::st fetchall_arrayref failed: fetch() without execute() at /usr/share/koha/lib/C4/Letters.pm line 198, <DATA> line 522., referer: https://my.koha.edu/cgi-bin/koha/opac-user.pl

If you look at the logic, you'll agree that "SELECT * FROM alert WHERE" is not a valid SQL query.

Code should assemble bind name/value pairs in a hash instead of appending to the query and pushing onto an array.  Then build the WHERE clause at the end only when hash is populated.
Comment 1 Joe Atzberger 2011-07-12 04:02:33 UTC
Alternatively, the standard hack of "SELECT ... WHERE 1 AND ..." could be used here.
Comment 2 Jonathan Druart 2015-03-27 09:57:13 UTC
You are not allowed to use Koha with the DB user.