49 public function __construct( $importer, $upload, $interwiki, $reason =
"" ) {
50 $this->mOriginalPageOutCallback =
51 $importer->setPageOutCallback( [ $this,
'reportPage' ] );
52 $this->mOriginalLogCallback =
53 $importer->setLogItemCallback( [ $this,
'reportLogItem' ] );
54 $importer->setNoticeCallback( [ $this,
'reportNotice' ] );
55 $this->mIsUpload = $upload;
56 $this->mInterwiki = $interwiki;
57 $this->reason = is_string( $reason ) ? $reason :
"";
96 $successCount, $pageInfo ) {
97 call_user_func_array( $this->mOriginalPageOutCallback, func_get_args() );
99 if ( $pageIdentity ===
null ) {
100 # Invalid or non-importable title; a notice is already displayed
105 $services = MediaWikiServices::getInstance();
106 $linkRenderer = $services->getLinkRenderer();
107 if ( $successCount > 0 ) {
111 "<li>" . $linkRenderer->makeLink( $pageIdentity ) .
" " .
113 $this->msg(
'import-revision-count' )->numParams( $successCount )->escaped() .
118 $logParams = [
'4:number:count' => $successCount ];
119 if ( $this->mIsUpload ) {
120 $detail = $this->
msg(
'import-logentry-upload-detail' )->numParams(
121 $successCount )->inContentLanguage()->text();
124 $pageTitle = $foreignTitle->getFullText();
125 $fullInterwikiPrefix = $this->mInterwiki;
126 $this->getHookRunner()->onImportLogInterwikiLink(
127 $fullInterwikiPrefix, $pageTitle );
129 $interwikiTitleStr = $fullInterwikiPrefix .
':' . $pageTitle;
130 $interwiki =
'[[:' . $interwikiTitleStr .
']]';
131 $detail = $this->
msg(
'import-logentry-interwiki-detail' )->numParams(
132 $successCount )->params( $interwiki )->inContentLanguage()->text();
133 $action =
'interwiki';
134 $logParams[
'5:title-link:interwiki'] = $interwikiTitleStr;
136 if ( $this->reason ) {
137 $detail .= $this->
msg(
'colon-separator' )->inContentLanguage()->text()
141 $comment = CommentStoreComment::newUnsavedComment( $detail );
143 $revStore = $services->getRevisionStore();
144 $nullRevRecord =
$revStore->newNullRevision(
153 if ( $nullRevRecord !==
null ) {
154 $inserted =
$revStore->insertRevisionOn( $nullRevRecord, $dbw );
155 $nullRevId = $inserted->getId();
156 $parentRevId = $inserted->getParentId();
157 $page = $services->getWikiPageFactory()->newFromTitle( $pageIdentity );
160 $page->updateRevisionOn( $dbw, $inserted );
163 $this->getHookRunner()->onRevisionFromEditComplete(
164 $page, $inserted, $parentRevId, $this->
getUser(), $fakeTags
170 $logEntry->setTarget( $pageIdentity );
171 $logEntry->setComment( $this->reason );
172 $logEntry->setPerformer( $this->
getUser() );
173 $logEntry->setParameters( $logParams );
176 $logEntry->setAssociatedRevId( $nullRevId );
177 if ( count( $this->logTags ) ) {
178 $logEntry->addTags( $this->logTags );
180 $logid = $logEntry->insert();
181 $logEntry->publish( $logid );
183 $this->
getOutput()->addHTML(
"<li>" . $linkRenderer->makeKnownLink( $pageIdentity ) .
" " .
184 $this->msg(
'import-nonewrevisions' )->escaped() .
"</li>\n" );
190 if ( $this->mLogItemCount > 0 ) {
191 $msg = $this->
msg(
'imported-log-entries' )->numParams( $this->mLogItemCount )->parse();
192 $out->addHTML( Xml::tags(
'li',
null, $msg ) );
193 } elseif ( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) {
194 $out->addHTML(
"</ul>\n" );
196 return Status::newFatal(
'importnopages' );
198 $out->addHTML(
"</ul>\n" );
200 return Status::newGood( $this->mPageCount );