X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FLinker.php;h=ff4c7861108c282f7596721593ed7349e97c44e1;hp=d2936a99ed281bc80a2673d4a83bdeb8f2c4d50a;hb=25ee9366b06a44087e8f0cba1f2b27324259ef52;hpb=61702397aa04572251869935245c07a0821f6c4a diff --git a/includes/Linker.php b/includes/Linker.php index d2936a99ed..ff4c786110 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -191,7 +191,7 @@ class Linker { */ public static function getInvalidTitleDescription( IContextSource $context, $namespace, $title ) { // First we check whether the namespace exists or not. - if ( MWNamespace::exists( $namespace ) ) { + if ( MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $namespace ) ) { if ( $namespace == NS_MAIN ) { $name = $context->msg( 'blanknamespace' )->text(); } else { @@ -894,6 +894,12 @@ class Linker { * @since 1.16.3. $altUserName was added in 1.19. */ public static function userLink( $userId, $userName, $altUserName = false ) { + if ( $userName === '' ) { + wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' . + 'that need to be fixed?' ); + return wfMessage( 'empty-username' )->parse(); + } + $classes = 'mw-userlink'; $page = null; if ( $userId == 0 ) { @@ -936,6 +942,12 @@ class Linker { $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null, $useParentheses = true ) { + if ( $userText === '' ) { + wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' . + 'that need to be fixed?' ); + return ' ' . wfMessage( 'empty-username' )->parse(); + } + global $wgUser, $wgDisableAnonTalk, $wgLang; $talkable = !( $wgDisableAnonTalk && $userId == 0 ); $blockable = !( $flags & self::TOOL_LINKS_NOBLOCK ); @@ -1002,10 +1014,13 @@ class Linker { * @param int $userId User identifier * @param string $userText User name or IP address * @param int|null $edits User edit count (optional, for performance) + * @param bool $useParentheses (optional) Wrap comments in parentheses where needed * @return string */ - public static function userToolLinksRedContribs( $userId, $userText, $edits = null ) { - return self::userToolLinks( $userId, $userText, true, 0, $edits, false ); + public static function userToolLinksRedContribs( + $userId, $userText, $edits = null, $useParentheses = true + ) { + return self::userToolLinks( $userId, $userText, true, 0, $edits, $useParentheses ); } /** @@ -1015,6 +1030,12 @@ class Linker { * @return string HTML fragment with user talk link */ public static function userTalkLink( $userId, $userText ) { + if ( $userText === '' ) { + wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' . + 'that need to be fixed?' ); + return wfMessage( 'empty-username' )->parse(); + } + $userTalkPage = new TitleValue( NS_USER_TALK, strtr( $userText, ' ', '_' ) ); $moreLinkAttribs['class'] = 'mw-usertoollinks-talk'; @@ -1031,6 +1052,12 @@ class Linker { * @return string HTML fragment with block link */ public static function blockLink( $userId, $userText ) { + if ( $userText === '' ) { + wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' . + 'that need to be fixed?' ); + return wfMessage( 'empty-username' )->parse(); + } + $blockPage = SpecialPage::getTitleFor( 'Block', $userText ); $moreLinkAttribs['class'] = 'mw-usertoollinks-block'; @@ -1046,6 +1073,12 @@ class Linker { * @return string HTML fragment with e-mail user link */ public static function emailLink( $userId, $userText ) { + if ( $userText === '' ) { + wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' . + 'that need to be fixed?' ); + return wfMessage( 'empty-username' )->parse(); + } + $emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText ); $moreLinkAttribs['class'] = 'mw-usertoollinks-mail'; return self::link( $emailPage, @@ -1269,7 +1302,12 @@ class Linker { ([^[]*) # 3. link trail (the text up until the next link) /x', function ( $match ) use ( $title, $local, $wikiId ) { - $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|'; + $services = MediaWikiServices::getInstance(); + + $medians = '(?:'; + $medians .= preg_quote( + $services->getNamespaceInfo()->getCanonicalName( NS_MEDIA ), '/' ); + $medians .= '|'; $medians .= preg_quote( MediaWikiServices::getInstance()->getContentLanguage()->getNsText( NS_MEDIA ), '/' @@ -1377,8 +1415,9 @@ class Linker { $wikiId, $linkTarget->getNamespace() === 0 ? $linkTarget->getDBkey() - : MWNamespace::getCanonicalName( $linkTarget->getNamespace() ) . ':' - . $linkTarget->getDBkey(), + : MediaWikiServices::getInstance()->getNamespaceInfo()-> + getCanonicalName( $linkTarget->getNamespace() ) . + ':' . $linkTarget->getDBkey(), $linkTarget->getFragment() ), $text, @@ -1413,7 +1452,10 @@ class Linker { # Some namespaces don't allow subpages, # so only perform processing if subpages are allowed - if ( $contextTitle && MWNamespace::hasSubpages( $contextTitle->getNamespace() ) ) { + if ( + $contextTitle && MediaWikiServices::getInstance()->getNamespaceInfo()-> + hasSubpages( $contextTitle->getNamespace() ) + ) { $hash = strpos( $target, '#' ); if ( $hash !== false ) { $suffix = substr( $target, $hash );