/** * @see Store::changeTitle() * @since 1.6 */ public function changeTitle(Title $oldtitle, Title $newtitle, $pageid, $redirid = 0) { $oldWikiPage = DIWikiPage::newFromTitle($oldtitle); $newWikiPage = DIWikiPage::newFromTitle($newtitle); $oldExpResource = Exporter::getInstance()->getDataItemExpElement($oldWikiPage); $newExpResource = Exporter::getInstance()->getDataItemExpElement($newWikiPage); $namespaces = array($oldExpResource->getNamespaceId() => $oldExpResource->getNamespace()); $namespaces[$newExpResource->getNamespaceId()] = $newExpResource->getNamespace(); $oldUri = TurtleSerializer::getTurtleNameForExpElement($oldExpResource); $newUri = TurtleSerializer::getTurtleNameForExpElement($newExpResource); // do this only here, so Imported from is not moved too early $this->baseStore->changeTitle($oldtitle, $newtitle, $pageid, $redirid); $sparqlDatabase = $this->getConnection(); $sparqlDatabase->insertDelete("?s ?p {$newUri}", "?s ?p {$oldUri}", "?s ?p {$oldUri}", $namespaces); if ($oldtitle->getNamespace() === SMW_NS_PROPERTY) { $sparqlDatabase->insertDelete("?s {$newUri} ?o", "?s {$oldUri} ?o", "?s {$oldUri} ?o", $namespaces); } /** * @since 2.3 Moved UpdateJob to the base-store to ensurethat both stores * operate similar when dealing with redirects * * @note Note that we cannot change oldUri to newUri in triple subjects, * since some triples change due to the move. */ // #566 $redirid == 0 indicates a `move` not a redirect action if ($redirid == 0) { $this->doSparqlDataDelete($oldWikiPage); } }
private function handleYetUnknownRedirectTarget(SemanticData $semanticData, DIWikiPage $target) { // Only keep the reference to safeguard that even in case of a text keeping // its annotations there are removed from the Store. A redirect is not // expected to contain any other annotation other than that of the redirect // target $subject = $semanticData->getSubject(); $semanticData = new SemanticData($subject); $semanticData->addPropertyObjectValue(new DIProperty('_REDI'), $target); // Force a manual changeTitle before the general update otherwise // #redirect can cause an inconsistent data container as observed in #895 $this->store->changeTitle($subject->getTitle(), $target->getTitle(), $subject->getTitle()->getArticleID(), $target->getTitle()->getArticleID()); $dispatchContext = EventHandler::getInstance()->newDispatchContext(); $dispatchContext->set('title', $subject->getTitle()); EventHandler::getInstance()->getEventDispatcher()->dispatch('factbox.cache.delete', $dispatchContext); return $semanticData; }