44 # Sneak a single revision into place
45 $user = $importableRevision->getUserObj() ?:
User::newFromName( $importableRevision->getUser() );
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();
71 if ( $importableRevision->getSha1Base36() !==
false ) {
72 $prior = $dbw->selectField(
'revision',
'1',
73 [
'rev_page' => $pageId,
74 'rev_timestamp' => $dbw->timestamp( $importableRevision->getTimestamp() ),
75 'rev_sha1' => $importableRevision->getSha1Base36() ],
80 $this->logger->debug( __METHOD__ .
": skipping existing revision for [[" .
81 $importableRevision->getTitle()->getPrefixedText() .
"]], timestamp " .
82 $importableRevision->getTimestamp() .
"\n" );
91 $this->logger->debug( __METHOD__ .
': got invalid $pageId when importing revision of [[' .
92 $importableRevision->getTitle()->getPrefixedText() .
']], timestamp ' .
93 $importableRevision->getTimestamp() .
"\n" );
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,
125 'timestamp' => $importableRevision->getTimestamp(),
126 'minor_edit' => $importableRevision->getMinor(),
127 'parent_id' => $prevId,
129 $revision->insertOn( $dbw );
130 $changed = $page->updateIfNewerOn( $dbw, $revision );
132 if ( $changed !==
false && $this->doUpdates ) {
133 $this->logger->debug( __METHOD__ .
": running updates\n" );
135 $page->doEditUpdates(
138 [
'created' => $created,
'oldcountable' =>
'no-change' ]