From: umherirrender Date: Sat, 14 Mar 2015 11:17:24 +0000 (+0100) Subject: Fix IRC lines for blocks published with the old logging system X-Git-Tag: 1.31.0-rc.0~12097^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=68c945d7963ca5de44ed67e59b11f448851f3cd9;p=lhc%2Fweb%2Fwiklou.git Fix IRC lines for blocks published with the old logging system The CheckUser and GlobalBlocking extension are inserting the block logs over the old logging system, where the keys are numeric. This case is not known when building the irc line, because that was already migrated to just get the new style. Added compatibility code for legacy rows. Needs the legacy flag also in ManualLogEntry to make this happen, because it is using the LogFormatter of the new logging system to format the actionText. Have not found the old way for block/reblock, so just for block/block. Bug: T92713 Follow-Up: Ibc7fcaa5a952ff90d42a6477da4baa429f3de64b Change-Id: I08aea8399ce766e98c1a76e237169f220c6cc751 --- diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index 85a305243f..e9b479bc41 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -370,6 +370,9 @@ class ManualLogEntry extends LogEntryBase { /** @var int ID of the log entry */ protected $id; + /** @var bool Whether this is a legacy log entry */ + protected $legacy = false; + /** * Constructor. * @@ -459,6 +462,16 @@ class ManualLogEntry extends LogEntryBase { $this->comment = $comment; } + /** + * Set the 'legacy' flag + * + * @since 1.25 + * @param bool $legacy + */ + public function setLegacy( $legacy ) { + $this->legacy = $legacy; + } + /** * TODO: document * @@ -641,6 +654,14 @@ class ManualLogEntry extends LogEntryBase { return $this->comment; } + /** + * @since 1.25 + * @return bool + */ + public function isLegacy() { + return $this->legacy; + } + public function getDeleted() { return (int)$this->deleted; } diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index 16cf5a1530..ce6e0adbf0 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -336,8 +336,17 @@ class LogFormatter { switch ( $entry->getSubtype() ) { case 'block': global $wgContLang; - $duration = $wgContLang->translateBlockExpiry( $parameters['5::duration'] ); - $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'], $wgContLang ); + // Keep compatibility with extensions by checking for + // new key (5::duration/6::flags) or old key (0/optional 1) + if ( $entry->isLegacy() ) { + $rawDuration = $parameters[0]; + $rawFlags = isset( $parameters[1] ) ? $parameters[1] : ''; + } else { + $rawDuration = $parameters['5::duration']; + $rawFlags = $parameters['6::flags']; + } + $duration = $wgContLang->translateBlockExpiry( $rawDuration ); + $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $wgContLang ); $text = wfMessage( 'blocklogentry' ) ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped(); break; diff --git a/includes/logging/LogPage.php b/includes/logging/LogPage.php index 30dee812a8..82e5808af6 100644 --- a/includes/logging/LogPage.php +++ b/includes/logging/LogPage.php @@ -422,6 +422,10 @@ class LogPage { $logEntry->setTarget( $target ); $logEntry->setPerformer( $doer ); $logEntry->setParameters( $params ); + // All log entries using the LogPage to insert into the logging table + // are using the old logging system and therefore the legacy flag is + // needed to say the LogFormatter the parameters have numeric keys + $logEntry->setLegacy( true ); $formatter = LogFormatter::newFromEntry( $logEntry ); $context = RequestContext::newExtraneousContext( $target );