+ // @fixme Needs updating the *_from_namespace fields in categorylinks,
+ // pagelinks, templatelinks and imagelinks.
+
+ return true;
+ }
+
+ /**
+ * Determine if we can merge a page.
+ * We check if an inaccessible revision would become the latest and
+ * deny the merge if so -- it's theoretically possible to update the
+ * latest revision, but opens a can of worms -- search engine updates,
+ * recentchanges review, etc.
+ *
+ * @param integer $id The page_id
+ * @param Title $newTitle The new title
+ * @param string $logStatus This is set to the log status message on failure
+ * @return bool
+ */
+ private function canMerge( $id, Title $newTitle, &$logStatus ) {
+ $latestDest = Revision::newFromTitle( $newTitle, 0, Revision::READ_LATEST );
+ $latestSource = Revision::newFromPageId( $id, 0, Revision::READ_LATEST );
+ if ( $latestSource->getTimestamp() > $latestDest->getTimestamp() ) {
+ $logStatus = 'cannot merge since source is later';
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Merge page histories
+ *
+ * @param integer $id The page_id
+ * @param Title $newTitle The new title
+ */
+ private function mergePage( $id, Title $newTitle ) {
+ $destId = $newTitle->getArticleId();
+ $this->db->begin( __METHOD__ );
+ $this->db->update( 'revision',
+ // SET
+ array( 'rev_page' => $destId ),
+ // WHERE
+ array( 'rev_page' => $id ),
+ __METHOD__ );
+
+ $this->db->delete( 'page', array( 'page_id' => $id ), __METHOD__ );
+
+ // @fixme Need WikiPage::doDeleteUpdates() or similar to avoid orphan
+ // rows in the links tables.
+
+ $this->db->commit( __METHOD__ );