SQL syntax error causing search failure
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Expired
|
Undecided
|
Unassigned |
Bug Description
Opening a new bug for this issue, because (given how much time has passed) it's probably unrelated to the original problem on bug 547776: https:/
Hi Penny - this seems to be happening in the latest version also. It is specifically with the Portfolio Search.
When you enable this and try a search in the block it returns the below:
'A nonrecoverable error occurred. This probably means you have encountered a bug in the system'
I checked server logs and found this too:
(lib/dml.php:484) Failed to get a recordset: mysql error: [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 '), referer: http://
[WAR] 63 (lib/dml.php:484) OR, referer: http://
[WAR] 63 (lib/dml.php:484) (LOWER(at.tag) = 'test'), referer: http://
[WAR] 63 (lib/dml.php:484) ) LIMI' at line 5] in EXECUTE(", referer: http://
[WAR] 63 (lib/dml.php:484) SELECT, referer: http://
[WAR] 63 (lib/dml.php:484) a.id, a.artefacttype, a.title, a.description, referer: http://
[WAR] 63 (lib/dml.php:484) FROM, referer: http://
[WAR] 63 (lib/dml.php:484) "artefact" a, referer: http://
[WAR] 63 (lib/dml.php:484) LEFT JOIN "artefact_tag" at ON (at.artefact = a.id), referer: http://
[WAR] 63 (lib/dml.php:484) WHERE, referer: http://
[WAR] 63 (lib/dml.php:484) a.owner = '10', referer: http://
[WAR] 63 (lib/dml.php:484) AND (, referer: http://
[WAR] 63 (lib/dml.php:484) (), referer: http://
[WAR] 63 (lib/dml.php:484) OR, referer: http://
63 (lib/dml.php:484) (LOWER(at.tag) = 'test'), referer: http://
63 (lib/dml.php:484) ) LIMIT 10"), referer: http://
63 (lib/dml.php:484) Command was: , referer: http://
63 (lib/dml.php:484) SELECT, referer: http://
[WAR] 63 (lib/dml.php:484) a.id, a.artefacttype, a.title, a.description, referer: http://
[WAR] 63 (lib/dml.php:484) FROM, referer: http://
[WAR] 63 (lib/dml.php:484) LEFT JOIN "artefact_tag" at ON (at.artefact = a.id), referer: http://
[WAR] 63 (lib/dml.php:484) WHERE, referer: http://
[WAR] 63 (lib/dml.php:484) a.owner = ?, referer: http://
[] [WAR] 63 (lib/dml.php:484) AND (, referer: http://
] [WAR] 63 (lib/dml.php:484) (), referer: http://
[WAR] 63 (lib/dml.php:484) OR, referer: http://
[WAR] 63 (lib/dml.php:484) (LOWER(at.tag) = ?), referer: http://
[WAR] 63 (lib/dml.php:484) ) and values was (10,test), referer: http://
Call stack (most recent first):, referer: http://
* get_recordset_
SELECT, referer: http://
* get_records_
* PluginSearchInt
* call_user_
* call_static_
* search_
, referer: http://
As the error stack says, the underyling cause here is a SQL syntax error. It's running this query, which has an empty () in the middle of the WHERE clause:
SELECT
(LOWER( at.tag) = 'test')
a.id, a.artefacttype, a.title, a.description
FROM
"artefact" a
LEFT JOIN "artefact_tag" at ON (at.artefact = a.id)
WHERE
a.owner = '10'
AND (
()
OR
)
LIMIT 10
I suspect this'll be a bug in the search code, where it's generating a series of search criteria to join together with ORs, and one of them winds up being an empty string or a boolean false.