Loris: [Utilities] Issue with getSiteList function

Created on 7 May 2020  路  6Comments  路  Source: aces/Loris

Describe the bug
When calling the function getSiteList(false, true), I get the following error:

[Thu May 07 11:43:26.167770 2020] [php7:warn] [pid 23155] [client 132.216.238.74:58908] PHP Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 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 'AND CenterID <> 1' at line 1 in /var/www/loris/php/libraries/Database.class.inc on line 691, referer: http://hrabalais-dev.loris.ca/issue_tracker/

23.0.0-testing Beginner Friendly Bug

All 6 comments

if you look at the code of that function you can see that the WHERE is part of one of the if statements, that should be brought out of the if statement to avoid a syntax error.

@christinerogers this is an easy one for GSOCs

thanks @ridz1208 I'll take you off and re-assign it quickly

Does this error happen only when the second param is false: getSiteList(false, false)?

the error occurs when the first if statement is skipped and the second is entered. but for testing, all combinations should be tested

Sure, I tested them all.

I'd say we should update the unit tests but it looks like the getSiteList unit test works by mocking pselect, so it wouldn't have caught this error even if all possibilities were tested..

Was this page helpful?
0 / 5 - 0 ratings