X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flogging%2FLogFormatter.php;h=bc0491f4cf01de4f414edf1c942e50c04d617aa4;hb=8f0b4332c5702d424322b2932afb30036b5e7d30;hp=a64fee1e5073c18d80002c798abf62f3e7413b82;hpb=adae996840b9e782f6e14b21c433a83e37c3a74e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index a64fee1e50..bc0491f4cf 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 @@ -166,8 +193,8 @@ class LogFormatter { } /** - * Even uglier hack to maintain backwards compatibilty with IRC bots - * (bug 34508). + * Even uglier hack to maintain backwards compatibility with IRC bots + * (T36508). * @see getActionText() * @return string Text */ @@ -187,8 +214,8 @@ class LogFormatter { } /** - * Even uglier hack to maintain backwards compatibilty with IRC bots - * (bug 34508). + * Even uglier hack to maintain backwards compatibility with IRC bots + * (T36508). * @see getActionText() * @return string Text */ @@ -234,19 +261,15 @@ class LogFormatter { $text = wfMessage( 'undeletedarticle' ) ->rawParams( $target )->inContentLanguage()->escaped(); break; - // @codingStandardsIgnoreStart Long line //case 'revision': // Revision deletion //case 'event': // Log deletion // see https://github.com/wikimedia/mediawiki/commit/a9c243b7b5289dad204278dbe7ed571fd914e395 //default: - // @codingStandardsIgnoreEnd } break; case 'patrol': - // @codingStandardsIgnoreStart Long line // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff - // @codingStandardsIgnoreEnd // Create a diff link to the patrolled revision if ( $entry->getSubtype() === 'patrol' ) { $diffLink = htmlspecialchars( @@ -353,7 +376,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 +390,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(); @@ -609,12 +640,13 @@ class LogFormatter { * @return string */ protected function makePageLink( Title $title = null, $parameters = [], $html = null ) { + if ( !$title instanceof Title ) { + throw new MWException( 'Expected title, got null' ); + } if ( !$this->plaintext ) { - $link = Linker::link( $title, $html, [], $parameters ); + $html = $html !== null ? new HtmlArmor( $html ) : $html; + $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters ); } else { - if ( !$title instanceof Title ) { - throw new MWException( "Expected title, got null" ); - } $link = '[[' . $title->getPrefixedText() . ']]'; } @@ -831,10 +863,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':