X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialImport.php;h=beb454d669f899b6847dc702e35f3b39af620f19;hp=c58af603d2722f6184d86af735493bb3b12353e8;hb=fb79f30319b9ad2a7eb0f5f4d1668143ec8f963e;hpb=72b9240497311a2fa5f5b76d9e8bb953dc59853f
diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php
index c58af603d2..beb454d669 100644
--- a/includes/specials/SpecialImport.php
+++ b/includes/specials/SpecialImport.php
@@ -24,6 +24,8 @@
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* MediaWiki page data importer
*
@@ -44,9 +46,6 @@ class SpecialImport extends SpecialPage {
private $pageLinkDepth;
private $importSources;
- /**
- * Constructor
- */
public function __construct() {
parent::__construct( 'Import', 'import' );
}
@@ -174,10 +173,8 @@ class SpecialImport extends SpecialPage {
$out = $this->getOutput();
if ( !$source->isGood() ) {
- $out->wrapWikiMsg(
- "
\n$1\n
",
- [ 'importfailed', $source->getWikiText() ]
- );
+ $out->addWikiText( "\n" .
+ $this->msg( 'importfailed', $source->getWikiText() )->parse() . "\n
" );
} else {
$importer = new WikiImporter( $source->value, $this->getConfig() );
if ( !is_null( $this->namespace ) ) {
@@ -534,6 +531,7 @@ class SpecialImport extends SpecialPage {
*/
class ImportReporter extends ContextSource {
private $reason = false;
+ private $logTags = [];
private $mOriginalLogCallback = null;
private $mOriginalPageOutCallback = null;
private $mLogItemCount = 0;
@@ -556,6 +554,16 @@ class ImportReporter extends ContextSource {
$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( "\n" );
}
@@ -592,12 +600,12 @@ class ImportReporter extends ContextSource {
}
$this->mPageCount++;
-
+ $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
if ( $successCount > 0 ) {
// prevents jumbling of the versions count
// in RTL wikis in case the page title is LTR
$this->getOutput()->addHTML(
- "- " . Linker::linkKnown( $title ) . " " .
+ "
- " . $linkRenderer->makeLink( $title ) . " " .
"" .
$this->msg( 'import-revision-count' )->numParams( $successCount )->escaped() .
"" .
@@ -626,14 +634,6 @@ class ImportReporter extends ContextSource {
. $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();
@@ -645,8 +645,9 @@ class ImportReporter extends ContextSource {
$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 );
@@ -655,8 +656,24 @@ class ImportReporter extends ContextSource {
[ $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( "
- " . Linker::linkKnown( $title ) . " " .
+ $this->getOutput()->addHTML( "
- " . $linkRenderer->makeKnownLink( $title ) . " " .
$this->msg( 'import-nonewrevisions' )->escaped() . "
\n" );
}
}