Make userLink() not fail too hard on false and null.
This works around an issue in Flow, which sometimes passes false for a user name. Bug: T224095 Change-Id: I14dc52f7199012dc35605f3170b06eb1719165a7
This commit is contained in:
parent
546770cef3
commit
e9e50ad014
2 changed files with 6 additions and 3 deletions
|
|
@ -894,7 +894,7 @@ class Linker {
|
|||
* @since 1.16.3. $altUserName was added in 1.19.
|
||||
*/
|
||||
public static function userLink( $userId, $userName, $altUserName = false ) {
|
||||
if ( $userName === '' ) {
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ class LinkerTest extends MediaWikiLangTestCase {
|
|||
] );
|
||||
|
||||
// We'd also test the warning, but injecting a mock logger into a static method is tricky.
|
||||
if ( $userName === '' ) {
|
||||
if ( !$userName ) {
|
||||
Wikimedia\suppressWarnings();
|
||||
}
|
||||
$actual = Linker::userLink( $userId, $userName, $altUserName );
|
||||
if ( $userName === '' ) {
|
||||
if ( !$userName ) {
|
||||
Wikimedia\restoreWarnings();
|
||||
}
|
||||
|
||||
|
|
@ -37,6 +37,9 @@ class LinkerTest extends MediaWikiLangTestCase {
|
|||
'Empty username, userid 0' => [ '(no username available)', 0, '' ],
|
||||
'Empty username, userid > 0' => [ '(no username available)', 73, '' ],
|
||||
|
||||
'false instead of username' => [ '(no username available)', 73, false ],
|
||||
'null instead of username' => [ '(no username available)', 0, null ],
|
||||
|
||||
# ## ANONYMOUS USER ########################################
|
||||
[
|
||||
'<a href="/wiki/Special:Contributions/JohnDoe" '
|
||||
|
|
|
|||
Loading…
Reference in a new issue