Page MenuHomePhabricator

Small bug in SMWSQLStore::getPropertiesSpecial()
Closed, ResolvedPublic

Description

Line 857 of /includes/storage/SMW_SQLStore.php should be changed from:

if ($requestoptions->limit >= 0) {

to

if ($requestoptions->limit > 0) {

That's because the "= 0" option catches the case where no limit is specified, at least for me, and thus places a "LIMIT " clause at the end of the query, leading to bad SQL. There's no need to allow for a limit of 0 rows, in any case.

Yaron Koren


Version: unspecified
Severity: normal

Details

Reference
bz11674

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:00 PM
bzimport set Reference to bz11674.
bzimport added a subscriber: Unknown Object (MLST).

Actually, the same thing also holds true for other functions within that same file, specifically lines 888, 917 and 1090. Of those, the first one (in getUnusedPropertiesSpecial()) is the most important for Semantic Forms' purposes.

OK, I made these fixes.

However, note that unused limits in SMW are usually set to -1, not to 0. A requested limit of 0 is actually used (by different code) for inline queries -- the query will then not print any results, but still check whether there had been any, and react accordingly (e.g. by showing "further results ..."). Normally, the consistent behaviour for SMW would thus be to return an empty array to any request with limit 0.