Merge "Chinese Conversion Table Update 2018-4"
[lhc/web/wiklou.git] / includes / logging / LogFormatter.php
index 35bb451..b07f20e 100644 (file)
@@ -51,13 +51,7 @@ class LogFormatter {
                global $wgLogActionsHandlers;
                $fulltype = $entry->getFullType();
                $wildcard = $entry->getType() . '/*';
-               $handler = '';
-
-               if ( isset( $wgLogActionsHandlers[$fulltype] ) ) {
-                       $handler = $wgLogActionsHandlers[$fulltype];
-               } elseif ( isset( $wgLogActionsHandlers[$wildcard] ) ) {
-                       $handler = $wgLogActionsHandlers[$wildcard];
-               }
+               $handler = $wgLogActionsHandlers[$fulltype] ?? $wgLogActionsHandlers[$wildcard] ?? '';
 
                if ( $handler !== '' && is_string( $handler ) && class_exists( $handler ) ) {
                        return new $handler( $entry );
@@ -227,8 +221,6 @@ class LogFormatter {
         * @return string Text
         */
        public function getIRCActionText() {
-               global $wgContLang;
-
                $this->plaintext = true;
                $this->irctext = true;
 
@@ -238,6 +230,7 @@ class LogFormatter {
                // Text of title the action is aimed at.
                $target = $entry->getTarget()->getPrefixedText();
                $text = null;
+               $contLang = MediaWikiServices::getInstance()->getContentLanguage();
                switch ( $entry->getType() ) {
                        case 'move':
                                switch ( $entry->getSubtype() ) {
@@ -383,12 +376,12 @@ class LogFormatter {
                                                        $rawDuration = $parameters['5::duration'];
                                                        $rawFlags = $parameters['6::flags'];
                                                }
-                                               $duration = $wgContLang->translateBlockExpiry(
+                                               $duration = $contLang->translateBlockExpiry(
                                                        $rawDuration,
                                                        null,
                                                        wfTimestamp( TS_UNIX, $entry->getTimestamp() )
                                                );
-                                               $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $wgContLang );
+                                               $flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $contLang );
                                                $text = wfMessage( 'blocklogentry' )
                                                        ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
                                                break;
@@ -397,12 +390,13 @@ class LogFormatter {
                                                        ->rawParams( $target )->inContentLanguage()->escaped();
                                                break;
                                        case 'reblock':
-                                               $duration = $wgContLang->translateBlockExpiry(
+                                               $duration = $contLang->translateBlockExpiry(
                                                        $parameters['5::duration'],
                                                        null,
                                                        wfTimestamp( TS_UNIX, $entry->getTimestamp() )
                                                );
-                                               $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'], $wgContLang );
+                                               $flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'],
+                                                       $contLang );
                                                $text = wfMessage( 'reblock-logentry' )
                                                        ->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
                                                break;
@@ -645,18 +639,23 @@ class LogFormatter {
         * @param Title|null $title The page
         * @param array $parameters Query parameters
         * @param string|null $html Linktext of the link as raw html
-        * @throws MWException
         * @return string
         */
        protected function makePageLink( Title $title = null, $parameters = [], $html = null ) {
                if ( !$title instanceof Title ) {
-                       throw new MWException( 'Expected title, got null' );
+                       $msg = $this->msg( 'invalidtitle' )->text();
+                       if ( $this->plaintext ) {
+                               return $msg;
+                       } else {
+                               return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg );
+                       }
                }
-               if ( !$this->plaintext ) {
+
+               if ( $this->plaintext ) {
+                       $link = '[[' . $title->getPrefixedText() . ']]';
+               } else {
                        $html = $html !== null ? new HtmlArmor( $html ) : $html;
                        $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters );
-               } else {
-                       $link = '[[' . $title->getPrefixedText() . ']]';
                }
 
                return $link;