Last modified: 2012-10-17 16:07:13 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T39575, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 37575 - Syntax error in SPARQL INSERT/DELETE DATA requests when default graph not set (1.7.1)
Syntax error in SPARQL INSERT/DELETE DATA requests when default graph not set...
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Unprioritized major (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-14 00:25 UTC by Jeen
Modified: 2012-10-17 16:07 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
patched file for properly use of default graph in SPARQL/Update query (23.24 KB, patch)
2012-09-07 15:29 UTC, Francesco Panico
Details

Description Jeen 2012-06-14 00:25:32 UTC
INSERT DATA and DELETE DATA requests generated by SMW_SparqlDatabase.php have illegal syntax when the default graph is not set: they have double curly brackets around the data:

 INSERT DATA {{ ... }}

Here is a fix for the insertData function:

	public function insertData( $triples, $extraNamespaces = array() ) {
		if ( $this->m_dataEndpoint !== '' ) {
			$turtle = self::getPrefixString( $extraNamespaces, false ) . $triples;
			return $this->doHttpPost( $turtle );
		} else {
			$sparql = self::getPrefixString( $extraNamespaces, true ) .
				"INSERT DATA { " .
				( ( $this->m_defaultGraph !== '' )? "GRAPH <{$this->m_defaultGraph}> { " : '' ) .
				" $triples } ";
				// close extra curly  bracket for graph clause
			       ( ( $this->m_defaultGraph !== '' )? " } " : " ";
			return $this->doUpdate( $sparql );
		}
	}

Same should work for deleteData as well. I have not verified if this same problem occurs anywhere else.
Comment 1 Francesco Panico 2012-09-07 15:29:01 UTC
Created attachment 11090 [details]
patched file for properly use of default graph in SPARQL/Update query

patched file for properly use of default graph in SPARQL/Update query
Comment 2 Francesco Panico 2012-09-07 15:30:23 UTC
I solved this problem modifying "\extensions\SemanticMediaWiki\includes\sparql\SMW_SparqlDatabase.php" 

I update 
-public function insertData( $triples, $extraNamespaces = array() ) {...} to fix the use of default graph
-public function doQuery( $sparql ) to add content type and charset
-public function doUpdate( $sparql ) to add content type and charset

I attach the patched file, so you have to download and substitute the old one.
Comment 3 Andre Klapper 2012-09-12 15:50:14 UTC
Comment on attachment 11090 [details]
patched file for properly use of default graph in SPARQL/Update query

[Correcting MIME Type and setting patch flag]
Comment 4 Markus Krötzsch 2012-10-17 16:07:13 UTC
Fixed by applying the suggested patch in https://gerrit.wikimedia.org/r/#/c/28369/

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links