Page MenuHomePhabricator

SMWSparqlDatabaseError Malformed query order by: Unresolved prefixed name
Closed, ResolvedPublic

Description

Author: gcarnevale

Description:
Fixed SMW_SparqlStoreQueryEngine.php file

OS: Centos 6.5
MediaWiki: 1.22.2

When I try to execute a sparql query with an order-by clause I have the following error:
Unexpected non-MediaWiki exception encountered, of type "SMWSparqlDatabaseError" . The output of sparql validator query is: "Unresolved prefixed name".

Output query example:

PREFIX wiki: http://.....
PREFIX rdf: http://.....
PREFIX rdfs: http://.....
PREFIX owl: http://.....
PREFIX swivt: http://.....
PREFIX property: <http:.....>
PREFIX xsd: http://.....
PREFIX yyy: http://.....
SELECT DISTINCT ?result WHERE {
?result xxx:some_instance ?v2 .
{ ?result rdf:type wiki:Categoria_instance . }
?result yyy:isVersionOf ?someVersion .

}
ORDER BY ASC(?v2)
OFFSET 0
LIMIT 501

The xxx prefix is not present in prefix list

A possible solution we found to fix this problem is to modify addMissingOrderByConditions method in the class extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStoreQueryEngine.php, adding the following line
$sparqlCondition->namespaces = array_merge($sparqlCondition->namespaces, $auxSparqlCondition->namespaces);

after line 942:

$sparqlCondition->weakConditions[$sparqlCondition->orderVariables[$propkey]] = $auxSparqlCondition->getWeakConditionString() . $auxSparqlCondition->getCondition();

I have attached to this issue the fixed class file.


Version: master
Severity: normal

Attached:

Details

Reference
bz62150

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:52 AM
bzimport set Reference to bz62150.
bzimport added a subscriber: Unknown Object (MLST).
Unknown Object (User) added a comment.Mar 3 2014, 7:31 PM

Thanks your contribution.

Your fix has been applied (see [0]). Please be so kind and test the changes [0] together with a feedback on [0].

PS: The next time you might want to fill the issue directly with [1] or even better create a pull request [2] (which triggers the test suite).

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/pull/215
[1] https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues
[2] https://github.com/SemanticMediaWiki/SemanticMediaWiki/pulls