44 # Sneak a single revision into place
47 $userId = intval( $user->getId() );
48 $userText = $user->getName();
51 $userText = $importableRevision->
getUser();
58 $page = WikiPage::factory( $importableRevision->
getTitle() );
59 $page->loadPageData(
'fromdbmaster' );
60 if ( !$page->exists() ) {
62 $pageId = $page->insertOn( $dbw );
66 $pageId = $page->getId();
72 $prior = $dbw->selectField(
'revision',
'1',
73 [
'rev_page' => $pageId,
74 'rev_timestamp' => $dbw->timestamp( $importableRevision->
getTimestamp() ),
80 $this->logger->debug( __METHOD__ .
": skipping existing revision for [[" .
81 $importableRevision->
getTitle()->getPrefixedText() .
"]], timestamp " .
91 $this->logger->debug( __METHOD__ .
': got invalid $pageId when importing revision of [[' .
92 $importableRevision->
getTitle()->getPrefixedText() .
']], timestamp ' .
100 $prevId = $dbw->selectField(
'revision',
'rev_id',
102 'rev_page' => $pageId,
103 'rev_timestamp <= ' . $dbw->addQuotes( $dbw->timestamp( $importableRevision->
getTimestamp() ) ),
107 'rev_timestamp DESC',
113 # @todo FIXME: Use original rev_id optionally (better for backups)
116 'title' => $importableRevision->
getTitle(),
118 'content_model' => $importableRevision->
getModel(),
119 'content_format' => $importableRevision->
getFormat(),
121 'text' => $importableRevision->
getContent()->serialize( $importableRevision->
getFormat() ),
122 'comment' => $importableRevision->
getComment(),
124 'user_text' => $userText,
126 'minor_edit' => $importableRevision->
getMinor(),
127 'parent_id' => $prevId,
129 $revision->insertOn( $dbw );
130 $changed = $page->updateIfNewerOn( $dbw, $revision );
132 $tags = $importableRevision->
getTags();
133 if ( $tags !== [] ) {
137 if ( $changed !==
false && $this->doUpdates ) {
138 $this->logger->debug( __METHOD__ .
": running updates\n" );
140 $page->doEditUpdates(
143 [
'created' => $created,
'oldcountable' =>
'no-change' ]