r86620 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86619‎ | r86620 | r86621 >
Date:11:22, 21 April 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
improved redirect handling; moves now work properly in SPARQL
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStore.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStore.php
@@ -28,21 +28,24 @@
2929 }
3030
3131 public function changeTitle( Title $oldtitle, Title $newtitle, $pageid, $redirid = 0 ) {
32 - parent::changeTitle( $oldtitle, $newtitle, $pageid, $redirid );
33 -
3432 $oldWikiPage = SMWDIWikiPage::newFromTitle( $oldtitle );
3533 $newWikiPage = SMWDIWikiPage::newFromTitle( $newtitle );
3634 $oldExpResource = SMWExporter::getDataItemExpElement( $oldWikiPage );
3735 $newExpResource = SMWExporter::getDataItemExpElement( $newWikiPage );
 36+ $namespaces = array( $oldExpResource->getNamespaceId() => $oldExpResource->getNamespace() );
 37+ $namespaces[$newExpResource->getNamespaceId()] = $newExpResource->getNamespace();
3838 $oldUri = SMWTurtleSerializer::getTurtleNameForExpElement( $oldExpResource );
3939 $newUri = SMWTurtleSerializer::getTurtleNameForExpElement( $newExpResource );
4040
 41+ parent::changeTitle( $oldtitle, $newtitle, $pageid, $redirid ); // do this only here, so Imported from is not moved too early
 42+
4143 $sparqlDatabase = smwfGetSparqlDatabase();
42 - //$sparqlDatabase->insertDelete( "$newUri ?p ?o", "$oldUri ?p ?o" ); // this moves properties that are not correct, reparse this page
43 - $sparqlDatabase->insertDelete( "?s ?p $newUri", "?s ?p $oldUri" );
 44+ $sparqlDatabase->insertDelete( "?s ?p $newUri", "?s ?p $oldUri", "?s ?p $oldUri", $namespaces );
4445 if ( $oldtitle->getNamespace() == SMW_NS_PROPERTY ) {
45 - $sparqlDatabase->insertDelete( "?s $newUri ?o", "?s $oldUri ?o" );
 46+ $sparqlDatabase->insertDelete( "?s $newUri ?o", "?s $oldUri ?o", "?s $oldUri ?o", $namespaces );
4647 }
 48+ // Note that we cannot change oldUri to newUri in triple subjects,
 49+ // since some triples change due to the move. Use SMWUpdateJob.
4750 $newUpdate = new SMWUpdateJob( $newtitle );
4851 $newUpdate->run();
4952 if ( $redirid != 0 ) { // update/create redirect page data

Status & tagging log