* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* MediaWiki page data importer
*
*/
class ImportReporter extends ContextSource {
private $reason = false;
+ private $logTags = [];
private $mOriginalLogCallback = null;
private $mOriginalPageOutCallback = null;
private $mLogItemCount = 0;
$this->reason = $reason;
}
+ /**
+ * Sets change tags to apply to the import log entry and null revision.
+ *
+ * @param array $tags
+ * @since 1.29
+ */
+ public function setChangeTags( array $tags ) {
+ $this->logTags = $tags;
+ }
+
function open() {
$this->getOutput()->addHTML( "<ul>\n" );
}
}
$this->mPageCount++;
-
+ $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
if ( $successCount > 0 ) {
// <bdi> prevents jumbling of the versions count
// in RTL wikis in case the page title is LTR
$this->getOutput()->addHTML(
- "<li>" . Linker::linkKnown( $title ) . " " .
+ "<li>" . $linkRenderer->makeLink( $title ) . " " .
"<bdi>" .
$this->msg( 'import-revision-count' )->numParams( $successCount )->escaped() .
"</bdi>" .
. $this->reason;
}
- $logEntry = new ManualLogEntry( 'import', $action );
- $logEntry->setTarget( $title );
- $logEntry->setComment( $this->reason );
- $logEntry->setPerformer( $this->getUser() );
- $logEntry->setParameters( $logParams );
- $logid = $logEntry->insert();
- $logEntry->publish( $logid );
-
$comment = $detail; // quick
$dbw = wfGetDB( DB_MASTER );
$latest = $title->getLatestRevID();
$this->getUser()
);
+ $nullRevId = null;
if ( !is_null( $nullRevision ) ) {
- $nullRevision->insertOn( $dbw );
+ $nullRevId = $nullRevision->insertOn( $dbw );
$page = WikiPage::factory( $title );
# Update page record
$page->updateRevisionOn( $dbw, $nullRevision );
[ $page, $nullRevision, $latest, $this->getUser() ]
);
}
+
+ // Create the import log entry
+ $logEntry = new ManualLogEntry( 'import', $action );
+ $logEntry->setTarget( $title );
+ $logEntry->setComment( $this->reason );
+ $logEntry->setPerformer( $this->getUser() );
+ $logEntry->setParameters( $logParams );
+ $logid = $logEntry->insert();
+ if ( count( $this->logTags ) ) {
+ $logEntry->setTags( $this->logTags );
+ }
+ // Make sure the null revision will be tagged as well
+ $logEntry->setAssociatedRevId( $nullRevId );
+
+ $logEntry->publish( $logid );
+
} else {
- $this->getOutput()->addHTML( "<li>" . Linker::linkKnown( $title ) . " " .
+ $this->getOutput()->addHTML( "<li>" . $linkRenderer->makeKnownLink( $title ) . " " .
$this->msg( 'import-nonewrevisions' )->escaped() . "</li>\n" );
}
}