X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLinker.php;h=4d684b5ea1aa1ac98016cf4e773e56a0ff731d9c;hb=f9f8dff40f0e2a50b617086c0a9915d8f8fbc2d7;hp=6acfda312124325001239611ac6288912fa5fc98;hpb=ddd1d4b9203aa3b516afbb099b6819a42df6faec;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Linker.php b/includes/Linker.php index 6acfda3121..4d684b5ea1 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 { @@ -1232,6 +1232,14 @@ class Linker { $sectionText = str_replace( '[[', '[[', $auto ); $section = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 ); + // Support: HHVM (T222857) + // The guessSectionNameFromStrippedText method returns a non-empty string + // that starts with "#". Before PHP 7 (and still on HHVM) substr() would + // return false if the start offset is the end of the string. + // On PHP 7+, it gracefully returns empty string instead. + if ( $section === false ) { + $section = ''; + } if ( $local ) { $sectionTitle = new TitleValue( NS_MAIN, '', $section ); } else { @@ -1302,7 +1310,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 ), '/' @@ -1410,8 +1423,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, @@ -1446,7 +1460,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 );