48 $this->mOriginalPageOutCallback =
49 $importer->setPageOutCallback( [ $this,
'reportPage' ] );
50 $this->mOriginalLogCallback =
51 $importer->setLogItemCallback( [ $this,
'reportLogItem' ] );
52 $importer->setNoticeCallback( [ $this,
'reportNotice' ] );
53 $this->mPageCount = 0;
54 $this->mIsUpload = $upload;
55 $this->mInterwiki = $interwiki;
95 $successCount, $pageInfo ) {
96 call_user_func_array( $this->mOriginalPageOutCallback, func_get_args() );
98 if ( $pageIdentity ===
null ) {
99 # Invalid or non-importable title; a notice is already displayed
104 $services = MediaWikiServices::getInstance();
105 $linkRenderer = $services->getLinkRenderer();
106 if ( $successCount > 0 ) {
110 "<li>" . $linkRenderer->makeLink( $pageIdentity ) .
" " .
112 $this->msg(
'import-revision-count' )->numParams( $successCount )->escaped() .
117 $logParams = [
'4:number:count' => $successCount ];
118 if ( $this->mIsUpload ) {
119 $detail = $this->
msg(
'import-logentry-upload-detail' )->numParams(
120 $successCount )->inContentLanguage()->text();
123 $pageTitle = $foreignTitle->getFullText();
125 $this->getHookRunner()->onImportLogInterwikiLink(
126 $fullInterwikiPrefix, $pageTitle );
128 $interwikiTitleStr = $fullInterwikiPrefix .
':' . $pageTitle;
129 $interwiki =
'[[:' . $interwikiTitleStr .
']]';
130 $detail = $this->
msg(
'import-logentry-interwiki-detail' )->numParams(
131 $successCount )->params( $interwiki )->inContentLanguage()->text();
132 $action =
'interwiki';
133 $logParams[
'5:title-link:interwiki'] = $interwikiTitleStr;
135 if ( $this->reason ) {
136 $detail .= $this->
msg(
'colon-separator' )->inContentLanguage()->text()
140 $comment = CommentStoreComment::newUnsavedComment( $detail );
142 $revStore = $services->getRevisionStore();
143 $nullRevRecord =
$revStore->newNullRevision(
152 if ( $nullRevRecord !==
null ) {
153 $inserted =
$revStore->insertRevisionOn( $nullRevRecord, $dbw );
154 $nullRevId = $inserted->getId();
155 $parentRevId = $inserted->getParentId();
156 $page = $services->getWikiPageFactory()->newFromTitle( $pageIdentity );
159 $page->updateRevisionOn( $dbw, $inserted );
162 $this->getHookRunner()->onRevisionFromEditComplete(
163 $page, $inserted, $parentRevId, $this->
getUser(), $fakeTags
169 $logEntry->setTarget( TitleValue::castPageToLinkTarget( $pageIdentity ) );
170 $logEntry->setComment( $this->reason );
171 $logEntry->setPerformer( $this->
getUser() );
172 $logEntry->setParameters( $logParams );
174 $logEntry->setAssociatedRevId( $nullRevId );
175 if ( count( $this->logTags ) ) {
176 $logEntry->addTags( $this->logTags );
178 $logid = $logEntry->insert();
179 $logEntry->publish( $logid );
181 $this->
getOutput()->addHTML(
"<li>" . $linkRenderer->makeKnownLink( $pageIdentity ) .
" " .
182 $this->msg(
'import-nonewrevisions' )->escaped() .
"</li>\n" );
188 if ( $this->mLogItemCount > 0 ) {
189 $msg = $this->
msg(
'imported-log-entries' )->numParams( $this->mLogItemCount )->parse();
190 $out->addHTML( Xml::tags(
'li',
null, $msg ) );
191 } elseif ( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) {
192 $out->addHTML(
"</ul>\n" );
194 return Status::newFatal(
'importnopages' );
196 $out->addHTML(
"</ul>\n" );
198 return Status::newGood( $this->mPageCount );