47 $this->mOriginalPageOutCallback =
48 $importer->setPageOutCallback( [ $this,
'reportPage' ] );
49 $this->mOriginalLogCallback =
50 $importer->setLogItemCallback( [ $this,
'reportLogItem' ] );
51 $importer->setNoticeCallback( [ $this,
'reportNotice' ] );
52 $this->mPageCount = 0;
53 $this->mIsUpload = $upload;
54 $this->mInterwiki = $interwiki;
94 $successCount, $pageInfo ) {
95 call_user_func_array( $this->mOriginalPageOutCallback, func_get_args() );
98 # Invalid or non-importable title; a notice is already displayed
103 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
104 if ( $successCount > 0 ) {
108 "<li>" . $linkRenderer->makeLink(
$title ) .
" " .
110 $this->msg(
'import-revision-count' )->numParams( $successCount )->escaped() .
115 $logParams = [
'4:number:count' => $successCount ];
116 if ( $this->mIsUpload ) {
117 $detail = $this->
msg(
'import-logentry-upload-detail' )->numParams(
118 $successCount )->inContentLanguage()->text();
121 $pageTitle = $foreignTitle->getFullText();
123 $this->getHookRunner()->onImportLogInterwikiLink(
124 $fullInterwikiPrefix, $pageTitle );
126 $interwikiTitleStr = $fullInterwikiPrefix .
':' . $pageTitle;
127 $interwiki =
'[[:' . $interwikiTitleStr .
']]';
128 $detail = $this->
msg(
'import-logentry-interwiki-detail' )->numParams(
129 $successCount )->params( $interwiki )->inContentLanguage()->text();
130 $action =
'interwiki';
131 $logParams[
'5:title-link:interwiki'] = $interwikiTitleStr;
133 if ( $this->reason ) {
134 $detail .= $this->
msg(
'colon-separator' )->inContentLanguage()->text()
138 $comment = CommentStoreComment::newUnsavedComment( $detail );
140 $revStore = MediaWikiServices::getInstance()->getRevisionStore();
141 $latest =
$title->getLatestRevID();
142 $nullRevRecord =
$revStore->newNullRevision(
151 if ( $nullRevRecord !==
null ) {
152 $inserted =
$revStore->insertRevisionOn( $nullRevRecord, $dbw );
153 $nullRevId = $inserted->getId();
154 $page = WikiPage::factory(
$title );
157 $page->updateRevisionOn( $dbw, $inserted );
160 $this->getHookRunner()->onRevisionFromEditComplete(
161 $page, $inserted, $latest, $this->
getUser(), $fakeTags
165 if ( $this->getHookContainer()->isRegistered(
'NewRevisionFromEditComplete' ) ) {
167 $nullRevision =
new Revision( $inserted );
168 $this->getHookRunner()->onNewRevisionFromEditComplete(
180 $logEntry->setTarget(
$title );
181 $logEntry->setComment( $this->reason );
182 $logEntry->setPerformer( $this->
getUser() );
183 $logEntry->setParameters( $logParams );
185 $logEntry->setAssociatedRevId( $nullRevId );
186 if ( count( $this->logTags ) ) {
187 $logEntry->addTags( $this->logTags );
189 $logid = $logEntry->insert();
190 $logEntry->publish( $logid );
192 $this->
getOutput()->addHTML(
"<li>" . $linkRenderer->makeKnownLink(
$title ) .
" " .
193 $this->msg(
'import-nonewrevisions' )->escaped() .
"</li>\n" );
199 if ( $this->mLogItemCount > 0 ) {
200 $msg = $this->
msg(
'imported-log-entries' )->numParams( $this->mLogItemCount )->parse();
201 $out->addHTML( Xml::tags(
'li',
null, $msg ) );
202 } elseif ( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) {
203 $out->addHTML(
"</ul>\n" );
205 return Status::newFatal(
'importnopages' );
207 $out->addHTML(
"</ul>\n" );
209 return Status::newGood( $this->mPageCount );