44 $this->mOriginalPageOutCallback =
45 $importer->setPageOutCallback( [ $this,
'reportPage' ] );
46 $this->mOriginalLogCallback =
47 $importer->setLogItemCallback( [ $this,
'reportLogItem' ] );
48 $importer->setNoticeCallback( [ $this,
'reportNotice' ] );
49 $this->mPageCount = 0;
50 $this->mIsUpload = $upload;
51 $this->mInterwiki = $interwiki;
91 $successCount, $pageInfo ) {
92 call_user_func_array( $this->mOriginalPageOutCallback, func_get_args() );
95 # Invalid or non-importable title; a notice is already displayed
100 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
101 if ( $successCount > 0 ) {
105 "<li>" . $linkRenderer->makeLink(
$title ) .
" " .
107 $this->msg(
'import-revision-count' )->numParams( $successCount )->escaped() .
112 $logParams = [
'4:number:count' => $successCount ];
113 if ( $this->mIsUpload ) {
114 $detail = $this->
msg(
'import-logentry-upload-detail' )->numParams(
115 $successCount )->inContentLanguage()->text();
118 $pageTitle = $foreignTitle->getFullText();
120 Hooks::run(
'ImportLogInterwikiLink', [ &$fullInterwikiPrefix, &$pageTitle ] );
122 $interwikiTitleStr = $fullInterwikiPrefix .
':' . $pageTitle;
123 $interwiki =
'[[:' . $interwikiTitleStr .
']]';
124 $detail = $this->
msg(
'import-logentry-interwiki-detail' )->numParams(
125 $successCount )->params( $interwiki )->inContentLanguage()->text();
126 $action =
'interwiki';
127 $logParams[
'5:title-link:interwiki'] = $interwikiTitleStr;
129 if ( $this->reason ) {
130 $detail .= $this->
msg(
'colon-separator' )->inContentLanguage()->text()
136 $latest =
$title->getLatestRevID();
137 $nullRevision = Revision::newNullRevision(
146 if ( !is_null( $nullRevision ) ) {
147 $nullRevId = $nullRevision->insertOn( $dbw );
148 $page = WikiPage::factory(
$title );
150 $page->updateRevisionOn( $dbw, $nullRevision );
152 'NewRevisionFromEditComplete',
153 [ $page, $nullRevision, $latest, $this->
getUser() ]
159 $logEntry->setTarget(
$title );
160 $logEntry->setComment( $this->reason );
161 $logEntry->setPerformer( $this->
getUser() );
162 $logEntry->setParameters( $logParams );
164 $logEntry->setAssociatedRevId( $nullRevId );
165 if ( count( $this->logTags ) ) {
166 $logEntry->addTags( $this->logTags );
168 $logid = $logEntry->insert();
169 $logEntry->publish( $logid );
171 $this->
getOutput()->addHTML(
"<li>" . $linkRenderer->makeKnownLink(
$title ) .
" " .
172 $this->msg(
'import-nonewrevisions' )->escaped() .
"</li>\n" );
178 if ( $this->mLogItemCount > 0 ) {
179 $msg = $this->
msg(
'imported-log-entries' )->numParams( $this->mLogItemCount )->parse();
180 $out->addHTML( Xml::tags(
'li',
null, $msg ) );
181 } elseif ( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) {
182 $out->addHTML(
"</ul>\n" );
184 return Status::newFatal(
'importnopages' );
186 $out->addHTML(
"</ul>\n" );
188 return Status::newGood( $this->mPageCount );