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: