X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialImport.php;h=a2930fcebe0cd8d7fe6bd74b3c761d084b21edf3;hb=581be97c46c584d04dd0c625cf6d0aa377a9b056;hp=c58af603d2722f6184d86af735493bb3b12353e8;hpb=864be4b56ebc2ad3a80d775aae6e11d14f06ed65;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php
index c58af603d2..a2930fcebe 100644
--- a/includes/specials/SpecialImport.php
+++ b/includes/specials/SpecialImport.php
@@ -24,6 +24,8 @@
* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* MediaWiki page data importer
*
@@ -534,6 +536,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 +559,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 +605,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 +639,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 +650,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 +661,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" );
}
}