X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLinker.php;h=39f43946d2fe7701b2d3c19352296705297f4ae5;hb=2c35b5be5f8fc477cdd7e4d832de58de3a6ca3d9;hp=ff4c7861108c282f7596721593ed7349e97c44e1;hpb=1d1bb122942d2ca6e557dc13e2d198276ce65ba6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Linker.php b/includes/Linker.php index ff4c786110..39f43946d2 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -555,7 +555,8 @@ class Linker { # Use manually specified thumbnail $manual_title = Title::makeTitleSafe( NS_FILE, $frameParams['manualthumb'] ); if ( $manual_title ) { - $manual_img = wfFindFile( $manual_title ); + $manual_img = MediaWikiServices::getInstance()->getRepoGroup() + ->findFile( $manual_title ); if ( $manual_img ) { $thumb = $manual_img->getUnscaledThumb( $handlerParams ); $manualthumb = true; @@ -693,7 +694,8 @@ class Linker { $label = $title->getPrefixedText(); } $encLabel = htmlspecialchars( $label ); - $currentExists = $time ? ( wfFindFile( $title ) != false ) : false; + $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title ); + $currentExists = $time ? ( $file != false ) : false; if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads ) && !$currentExists @@ -756,11 +758,13 @@ class Linker { * @since 1.16.3 * @param LinkTarget $title * @param string $html Pre-sanitized HTML - * @param string $time MW timestamp of file creation time + * @param string|false $time MW timestamp of file creation time * @return string HTML */ public static function makeMediaLinkObj( $title, $html = '', $time = false ) { - $img = wfFindFile( $title, [ 'time' => $time ] ); + $img = MediaWikiServices::getInstance()->getRepoGroup()->findFile( + $title, [ 'time' => $time ] + ); return self::makeMediaLinkFile( $title, $img, $html ); } @@ -894,8 +898,8 @@ 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 ' . + if ( $userName === '' || $userName === false || $userName === null ) { + wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' . 'that need to be fixed?' ); return wfMessage( 'empty-username' )->parse(); } @@ -943,7 +947,7 @@ class Linker { $useParentheses = true ) { if ( $userText === '' ) { - wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' . + wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' . 'that need to be fixed?' ); return ' ' . wfMessage( 'empty-username' )->parse(); } @@ -1031,7 +1035,7 @@ class Linker { */ public static function userTalkLink( $userId, $userText ) { if ( $userText === '' ) { - wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' . + wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' . 'that need to be fixed?' ); return wfMessage( 'empty-username' )->parse(); } @@ -1053,7 +1057,7 @@ class Linker { */ public static function blockLink( $userId, $userText ) { if ( $userText === '' ) { - wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' . + wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' . 'that need to be fixed?' ); return wfMessage( 'empty-username' )->parse(); } @@ -1232,15 +1236,22 @@ class Linker { $sectionText = str_replace( '[[', '[[', $auto ); $section = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 ); - if ( $local ) { - $sectionTitle = new TitleValue( NS_MAIN, '', $section ); - } else { - $sectionTitle = $title->createFragmentTarget( $section ); - } - if ( $sectionTitle ) { + // 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 !== '' && $section !== false ) { + if ( $local ) { + $sectionTitle = new TitleValue( NS_MAIN, '', $section ); + } else { + $sectionTitle = $title->createFragmentTarget( $section ); + } $auto = Linker::makeCommentLink( - $sectionTitle, $wgLang->getArrow() . $wgLang->getDirMark() . $sectionText, - $wikiId, 'noclasses' + $sectionTitle, + $wgLang->getArrow() . $wgLang->getDirMark() . $sectionText, + $wikiId, + 'noclasses' ); } }