From 7bcb879bc38379348686b22e9d1514e3dedb32e2 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 8 Feb 2012 19:52:04 +0000 Subject: [PATCH] Fixes for r96546 (bug 33167): * Made LegacyLogFormatter try to respect the 'plaintext' parameter. * Changed LogPage::addEntry() to use LogFormatter to get the action text as such calls to LogPage::actionText() are broken. * Added comment to LogPage::actionText(). It's only OK to call this from the legacy log formatter, fetched via the proper factory functions. * Converted CheckUser to using LogFormatter so that cuc_actiontext values work. Eventually, cuc_actiontext should be replaced with new cuc_params, cuc_log_type, and cuc_log_action fields, similar to the RC table. --- includes/logging/LogFormatter.php | 4 ++-- includes/logging/LogPage.php | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index 7c8645f185..322a250830 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -393,9 +393,9 @@ class LegacyLogFormatter extends LogFormatter { $entry->getType(), $entry->getSubtype(), $entry->getTarget(), - $this->context->getSkin(), + $this->plaintext ? null : $this->context->getSkin(), (array)$entry->getParameters(), - true + !$this->plaintext // whether to filter [[]] links ); $performer = $this->getPerformerElement(); diff --git a/includes/logging/LogPage.php b/includes/logging/LogPage.php index f4dd064110..bbb4de8f80 100644 --- a/includes/logging/LogPage.php +++ b/includes/logging/LogPage.php @@ -201,7 +201,8 @@ class LogPage { } /** - * Generate text for a log entry + * Generate text for a log entry. + * Only LogFormatter should call this function. * * @param $type String: log type * @param $action String: log action @@ -420,6 +421,7 @@ class LogPage { * @param $doer User object: the user doing the action * * @return bool|int|null + * @TODO: make this use LogEntry::saveContent() */ public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) { global $wgContLang; @@ -449,7 +451,16 @@ class LogPage { $this->doer = $doer; - $this->actionText = LogPage::actionText( $this->type, $action, $target, null, $params ); + $logEntry = new ManualLogEntry( $this->type, $action ); + $logEntry->setTarget( $target ); + $logEntry->setPerformer( $doer ); + $logEntry->setParameters( $params ); + + $formatter = LogFormatter::newFromEntry( $logEntry ); + $context = RequestContext::newExtraneousContext( $target ); + $formatter->setContext( $context ); + + $this->actionText = $formatter->getPlainActionText(); return $this->saveContent(); } -- 2.20.1