X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Flogging%2FLogFormatter.php;h=0f1e1f7f1e8f7cf5cf98b4b70ebe1f2eba79a73f;hb=c4145b2f087c0d8f46191456aa0e4cf83e7b1ba1;hp=a64fee1e5073c18d80002c798abf62f3e7413b82;hpb=b5906606e1aa1a795231fb813b766818b1dd6c25;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index a64fee1e50..0f1e1f7f1e 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -22,6 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later * @since 1.19 */ +use MediaWiki\Linker\LinkRenderer; +use MediaWiki\MediaWikiServices; /** * Implements the default log formatting. @@ -101,6 +103,11 @@ class LogFormatter { /** @var string */ protected $irctext = false; + /** + * @var LinkRenderer|null + */ + private $linkRenderer; + protected function __construct( LogEntry $entry ) { $this->entry = $entry; $this->context = RequestContext::getMain(); @@ -114,6 +121,26 @@ class LogFormatter { $this->context = $context; } + /** + * @since 1.30 + * @param LinkRenderer $linkRenderer + */ + public function setLinkRenderer( LinkRenderer $linkRenderer ) { + $this->linkRenderer = $linkRenderer; + } + + /** + * @since 1.30 + * @return LinkRenderer + */ + public function getLinkRenderer() { + if ( $this->linkRenderer !== null ) { + return $this->linkRenderer; + } else { + return MediaWikiServices::getInstance()->getLinkRenderer(); + } + } + /** * Set the visibility restrictions for displaying content. * If set to public, and an item is deleted, then it will be replaced @@ -167,7 +194,7 @@ class LogFormatter { /** * Even uglier hack to maintain backwards compatibilty with IRC bots - * (bug 34508). + * (T36508). * @see getActionText() * @return string Text */ @@ -188,7 +215,7 @@ class LogFormatter { /** * Even uglier hack to maintain backwards compatibilty with IRC bots - * (bug 34508). + * (T36508). * @see getActionText() * @return string Text */ @@ -353,7 +380,11 @@ class LogFormatter { $rawDuration = $parameters['5::duration']; $rawFlags = $parameters['6::flags']; } - $duration = $wgContLang->translateBlockExpiry( $rawDuration ); + $duration = $wgContLang->translateBlockExpiry( + $rawDuration, + null, + wfTimestamp( TS_UNIX, $entry->getTimestamp() ) + ); $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $wgContLang ); $text = wfMessage( 'blocklogentry' ) ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped(); @@ -363,7 +394,11 @@ class LogFormatter { ->rawParams( $target )->inContentLanguage()->escaped(); break; case 'reblock': - $duration = $wgContLang->translateBlockExpiry( $parameters['5::duration'] ); + $duration = $wgContLang->translateBlockExpiry( + $parameters['5::duration'], + null, + wfTimestamp( TS_UNIX, $entry->getTimestamp() ) + ); $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'], $wgContLang ); $text = wfMessage( 'reblock-logentry' ) ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped(); @@ -831,10 +866,12 @@ class LogFormatter { case 'title': case 'title-link': $title = Title::newFromText( $value ); - if ( $title ) { - $value = []; - ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" ); + if ( !$title ) { + // Huh? Do something halfway sane. + $title = SpecialPage::getTitleFor( 'Badtitle', $value ); } + $value = []; + ApiQueryBase::addTitleInfo( $value, $title, "{$name}_" ); return $value; case 'user':