Use explicit value checks where "0" is valid input
User "0", page "0" and edit summary "0" are all valid. Treating them as empty may cause subtle inconsistencies. Change-Id: I90a92bfb972cca840e5d8060dac3f116a22990db
This commit is contained in:
parent
cdabac07fb
commit
7f6385e851
6 changed files with 11 additions and 10 deletions
|
|
@ -143,7 +143,9 @@ class ApiQueryUserContribs extends ApiQueryBase {
|
|||
->caller( $fname )
|
||||
->limit( $limit )
|
||||
->whereUserNamePrefix( $this->params['userprefix'] )
|
||||
->where( $fromName ? $dbSecondary->buildComparison( $op, [ 'actor_name' => $fromName ] ) : [] )
|
||||
->where( $fromName !== false
|
||||
? $dbSecondary->buildComparison( $op, [ 'actor_name' => $fromName ] )
|
||||
: [] )
|
||||
->orderByName( $sort )
|
||||
->fetchUserIdentities();
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class BlockUtils {
|
|||
// This allows validateTarget() to return a "nosuchusershort" message,
|
||||
// which is needed for Special:Block.
|
||||
$canonicalName = $this->userNameUtils->getCanonical( $target );
|
||||
if ( $canonicalName ) {
|
||||
if ( $canonicalName !== false ) {
|
||||
return [
|
||||
new UserIdentityValue( 0, $canonicalName ),
|
||||
AbstractBlock::TYPE_USER
|
||||
|
|
|
|||
|
|
@ -3265,7 +3265,7 @@ class EditPage implements IEditObject {
|
|||
$this->addExplainConflictHeader();
|
||||
$this->editRevId = $this->page->getLatest();
|
||||
} else {
|
||||
if ( $this->section !== '' && $this->section !== 'new' && !$this->summary &&
|
||||
if ( $this->section !== '' && $this->section !== 'new' && $this->summary === '' &&
|
||||
!$this->preview && !$this->diff
|
||||
) {
|
||||
$sectionTitle = self::extractSectionTitle( $this->textbox1 ); // FIXME: use Content object
|
||||
|
|
|
|||
|
|
@ -727,16 +727,15 @@ class SpecialContributions extends IncludableSpecialPage {
|
|||
];
|
||||
}
|
||||
|
||||
$target = $this->opts['target'] ?? null;
|
||||
$target = $this->opts['target'] ?? '';
|
||||
$fields['target'] = [
|
||||
'type' => 'user',
|
||||
'default' => $target ?
|
||||
str_replace( '_', ' ', $target ) : '',
|
||||
'default' => str_replace( '_', ' ', $target ),
|
||||
'label' => $this->msg( 'sp-contributions-username' )->text(),
|
||||
'name' => 'target',
|
||||
'id' => 'mw-target-user-or-ip',
|
||||
'size' => 40,
|
||||
'autofocus' => !$target,
|
||||
'autofocus' => $target === '',
|
||||
'section' => 'contribs-top',
|
||||
'ipallowed' => true,
|
||||
'iprange' => true,
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ class SpecialListFiles extends IncludableSpecialPage {
|
|||
}
|
||||
// Sanitize usernames to avoid symbols in the title of page.
|
||||
$sanitizedUserName = $this->userNameUtils->getCanonical( $userName, UserRigorOptions::RIGOR_NONE );
|
||||
if ( $sanitizedUserName ) {
|
||||
if ( $sanitizedUserName !== false ) {
|
||||
$userName = $sanitizedUserName;
|
||||
}
|
||||
|
||||
if ( $userName ) {
|
||||
if ( $userName !== '' ) {
|
||||
$pageTitle = $this->msg( 'listfiles_subpage' )->plaintextParams( $userName );
|
||||
} else {
|
||||
$pageTitle = $this->msg( 'listfiles' );
|
||||
|
|
|
|||
|
|
@ -710,7 +710,7 @@ class SpecialUserRights extends SpecialPage {
|
|||
'user',
|
||||
'username',
|
||||
30,
|
||||
$this->mTarget ? str_replace( '_', ' ', $this->mTarget ) : '',
|
||||
$this->mTarget !== null ? str_replace( '_', ' ', $this->mTarget ) : '',
|
||||
[
|
||||
'class' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
|
||||
] + (
|
||||
|
|
|
|||
Loading…
Reference in a new issue