47 public function __construct( $importer, $upload, $interwiki, $reason =
"" ) {
48 $this->mOriginalPageOutCallback =
49 $importer->setPageOutCallback( [ $this,
'reportPage' ] );
50 $this->mOriginalLogCallback =
51 $importer->setLogItemCallback( [ $this,
'reportLogItem' ] );
52 $importer->setNoticeCallback( [ $this,
'reportNotice' ] );
53 $this->mIsUpload = $upload;
54 $this->mInterwiki = $interwiki;
55 $this->reason = is_string( $reason ) ? $reason :
"";
94 $successCount, $pageInfo ) {
95 call_user_func_array( $this->mOriginalPageOutCallback, func_get_args() );
97 if ( $pageIdentity ===
null ) {
98 # Invalid or non-importable title; a notice is already displayed
103 $services = MediaWikiServices::getInstance();
104 $linkRenderer = $services->getLinkRenderer();
105 if ( $successCount > 0 ) {
109 "<li>" . $linkRenderer->makeLink( $pageIdentity ) .
" " .
111 $this->msg(
'import-revision-count' )->numParams( $successCount )->escaped() .
116 $logParams = [
'4:number:count' => $successCount ];
117 if ( $this->mIsUpload ) {
118 $detail = $this->
msg(
'import-logentry-upload-detail' )->numParams(
119 $successCount )->inContentLanguage()->text();
122 $pageTitle = $foreignTitle->getFullText();
123 $fullInterwikiPrefix = $this->mInterwiki;
124 $this->getHookRunner()->onImportLogInterwikiLink(
125 $fullInterwikiPrefix, $pageTitle );
127 $interwikiTitleStr = $fullInterwikiPrefix .
':' . $pageTitle;
128 $interwiki =
'[[:' . $interwikiTitleStr .
']]';
129 $detail = $this->
msg(
'import-logentry-interwiki-detail' )->numParams(
130 $successCount )->params( $interwiki )->inContentLanguage()->text();
131 $action =
'interwiki';
132 $logParams[
'5:title-link:interwiki'] = $interwikiTitleStr;
134 if ( $this->reason ) {
135 $detail .= $this->
msg(
'colon-separator' )->inContentLanguage()->text()
139 $comment = CommentStoreComment::newUnsavedComment( $detail );
141 $revStore = $services->getRevisionStore();
142 $nullRevRecord =
$revStore->newNullRevision(
151 if ( $nullRevRecord !==
null ) {
152 $inserted =
$revStore->insertRevisionOn( $nullRevRecord, $dbw );
153 $nullRevId = $inserted->getId();
154 $parentRevId = $inserted->getParentId();
155 $page = $services->getWikiPageFactory()->newFromTitle( $pageIdentity );
158 $page->updateRevisionOn( $dbw, $inserted );
161 $this->getHookRunner()->onRevisionFromEditComplete(
162 $page, $inserted, $parentRevId, $this->
getUser(), $fakeTags
168 $logEntry->setTarget( $pageIdentity );
169 $logEntry->setComment( $this->reason );
170 $logEntry->setPerformer( $this->
getUser() );
171 $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 );