X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLinker.php;h=eb7a44f6b4d102e69a6069615f94b9f391cd3880;hb=134a2bbeb1f5c1c87c220332945fdf0140108306;hp=ff4c7861108c282f7596721593ed7349e97c44e1;hpb=a954426320529222df460aa9ac89c74950d610e0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Linker.php b/includes/Linker.php index ff4c786110..eb7a44f6b4 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -895,7 +895,7 @@ class Linker { */ public static function userLink( $userId, $userName, $altUserName = false ) { if ( $userName === '' ) { - 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(); } @@ -943,7 +943,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 +1031,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 +1053,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 +1232,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' ); } }