Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStore.php |
— | — | @@ -28,21 +28,24 @@ |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function changeTitle( Title $oldtitle, Title $newtitle, $pageid, $redirid = 0 ) { |
32 | | - parent::changeTitle( $oldtitle, $newtitle, $pageid, $redirid ); |
33 | | - |
34 | 32 | $oldWikiPage = SMWDIWikiPage::newFromTitle( $oldtitle ); |
35 | 33 | $newWikiPage = SMWDIWikiPage::newFromTitle( $newtitle ); |
36 | 34 | $oldExpResource = SMWExporter::getDataItemExpElement( $oldWikiPage ); |
37 | 35 | $newExpResource = SMWExporter::getDataItemExpElement( $newWikiPage ); |
| 36 | + $namespaces = array( $oldExpResource->getNamespaceId() => $oldExpResource->getNamespace() ); |
| 37 | + $namespaces[$newExpResource->getNamespaceId()] = $newExpResource->getNamespace(); |
38 | 38 | $oldUri = SMWTurtleSerializer::getTurtleNameForExpElement( $oldExpResource ); |
39 | 39 | $newUri = SMWTurtleSerializer::getTurtleNameForExpElement( $newExpResource ); |
40 | 40 | |
| 41 | + parent::changeTitle( $oldtitle, $newtitle, $pageid, $redirid ); // do this only here, so Imported from is not moved too early |
| 42 | + |
41 | 43 | $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 ); |
44 | 45 | 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 ); |
46 | 47 | } |
| 48 | + // Note that we cannot change oldUri to newUri in triple subjects, |
| 49 | + // since some triples change due to the move. Use SMWUpdateJob. |
47 | 50 | $newUpdate = new SMWUpdateJob( $newtitle ); |
48 | 51 | $newUpdate->run(); |
49 | 52 | if ( $redirid != 0 ) { // update/create redirect page data |