phan: Enable redundant_condition_detection

Remove duplicate casts
Suppress false positives

Bug: T248438
Change-Id: I2f89664a4bcd3b39b15e7cf850adda2f0c90ae6f
This commit is contained in:
Umherirrender 2020-06-15 12:46:22 +02:00
parent 7ba77c21c8
commit bc5cb7ae64
47 changed files with 78 additions and 20 deletions

View file

@ -89,11 +89,6 @@ $cfg['exclude_analysis_directory_list'] = [
'includes/libs/objectcache/utils/MemcachedClient.php',
];
// This helps a lot in discovering bad code, but unfortunately it will always fail for
// hooks + pass by reference, see phan issue #2943.
// @todo Enable when the issue above is resolved and we update our config!
$cfg['redundant_condition_detection'] = false;
// These are too spammy for now. TODO enable
$cfg['null_casts_as_any_type'] = true;
$cfg['scalar_implicit_cast'] = true;

View file

@ -2129,6 +2129,7 @@ ERROR;
$result['sectionanchor'] = '';
if ( $this->section == 'new' ) {
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $this->sectiontitle !== '' ) {
// Insert the section title above the content.
$content = $content->addSectionHeader( $this->sectiontitle );
@ -2190,6 +2191,7 @@ ERROR;
}
// If sectiontitle is set, use it, otherwise use the summary as the section title.
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $this->sectiontitle !== '' ) {
$sectionTitle = $this->sectiontitle;
} else {

View file

@ -541,6 +541,7 @@ define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
MWExceptionHandler::installHandler();
// T30798: $wgServer must be explicitly set
// @phan-suppress-next-line PhanSuspiciousValueComparisonInGlobalScope
if ( $wgServer === false ) {
throw new FatalError(
'$wgServer must be set in LocalSettings.php. ' .

View file

@ -793,6 +793,7 @@ class Title implements LinkTarget, IDBAccessObject {
$out .= $r2;
}
}
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $ord1 < 0x80 ) {
$out .= $r1;
}

View file

@ -156,7 +156,7 @@ class WebResponse {
wfDebugLog( 'cookie', 'ignored post-send cookie {cookie}', 'all', [
'cookie' => $cookie,
'data' => [
'name' => (string)$cookie,
'name' => $cookie,
'value' => (string)$value,
'expire' => (int)$expire,
'path' => (string)$options['path'],
@ -176,7 +176,7 @@ class WebResponse {
// we need to use the altered values from the hook here. (T198525)
$cookie = $options['prefix'] . $name;
$data = [
'name' => (string)$cookie,
'name' => $cookie,
'value' => (string)$value,
'expire' => (int)$expire,
'path' => (string)$options['path'],

View file

@ -99,7 +99,6 @@ class ApiExpandTemplates extends ApiBase {
if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) {
$parser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS );
$dom = $parser->preprocessToDom( $params['text'] );
// @phan-suppress-next-line PhanUndeclaredMethodInCallable
if ( is_callable( [ $dom, 'saveXML' ] ) ) {
// @phan-suppress-next-line PhanUndeclaredMethod
$xml = $dom->saveXML();

View file

@ -1311,6 +1311,7 @@ class ApiMain extends ApiBase {
[ '' ]
);
if ( $ifNoneMatch ) {
// @phan-suppress-next-line PhanImpossibleTypeComparison
if ( $ifNoneMatch === [ '*' ] ) {
// API responses always "exist"
$etag = '*';

View file

@ -347,6 +347,7 @@ class ApiQuery extends ApiBase {
$values = $pageSet->getNormalizedTitlesAsResult( $result );
if ( $values ) {
// @phan-suppress-next-line PhanRedundantCondition
$fit = $fit && $result->addValue( 'query', 'normalized', $values );
}
$values = $pageSet->getConvertedTitlesAsResult( $result );

View file

@ -426,6 +426,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
break;
default:
// @phan-suppress-next-line PhanImpossibleCondition
$this->dieContinueUsageIf( true );
}
@ -456,6 +457,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
// It didn't fit. Add elements one by one until the
// result is full.
ksort( $this->resultArr );
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( count( $this->cont ) >= 7 ) {
$startAt = $this->cont[6];
} else {
@ -481,6 +483,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
$hasRedirs = false;
$redirLinks = isset( $arr['redirlinks'] ) ? (array)$arr['redirlinks'] : [];
ksort( $redirLinks );
// @phan-suppress-next-line PhanSuspiciousValueComparisonInLoop
if ( count( $this->cont ) >= 8 && $pageID == $startAt ) {
$redirStartAt = $this->cont[7];
} else {

View file

@ -521,7 +521,6 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
Parser::OT_PREPROCESS
);
$dom = $parser->preprocessToDom( $t );
// @phan-suppress-next-line PhanUndeclaredMethodInCallable
if ( is_callable( [ $dom, 'saveXML' ] ) ) {
// @phan-suppress-next-line PhanUndeclaredMethod
$xml = $dom->saveXML();

View file

@ -119,7 +119,7 @@ class ApiUserrights extends ApiBase {
$r['userid'] = $user->getId();
list( $r['added'], $r['removed'] ) = $form->doSaveUserGroups(
// Don't pass null to doSaveUserGroups() for array params, cast to empty array
$user, (array)$add, (array)$params['remove'],
$user, $add, (array)$params['remove'],
$params['reason'], (array)$tags, $groupExpiries
);

View file

@ -565,6 +565,7 @@ class LocalisationCache {
}
}
} elseif ( $_fileType == 'aliases' ) {
// @phan-suppress-next-line PhanImpossibleCondition May be set in included file
if ( isset( $aliases ) ) {
$data['aliases'] = $aliases;
}
@ -867,6 +868,7 @@ class LocalisationCache {
}
# Fill in the fallback if it's not there already
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( ( $coreData['fallback'] === null || $coreData['fallback'] === false ) && $code === 'en' ) {
$coreData['fallback'] = false;
$coreData['originalFallbackSequence'] = $coreData['fallbackSequence'] = [];
@ -976,6 +978,7 @@ class LocalisationCache {
continue;
}
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
if ( $allData[$key] === null || $this->isMergeableKey( $key ) ) {
$this->mergeItem( $key, $allData[$key], $csData[$key] );
}

View file

@ -279,6 +279,7 @@ class DeferredUpdates {
$guiEx = $guiEx ?: ( $e instanceof ErrorPageError ? $e : null );
$exception = $exception ?: $e;
// Do the subqueue updates for $update until there are none
// @phan-suppress-next-line PhanImpossibleConditionInLoop
while ( $stackEntry['subqueue'] ) {
$duChild = reset( $stackEntry['subqueue'] );
$duChildKey = key( $stackEntry['subqueue'] );

View file

@ -142,6 +142,7 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob {
}
}
// @phan-suppress-next-next-line PhanImpossibleCondition
// phpcs:ignore Generic.CodeAnalysis.UnconditionalIfStatement.Found
if ( false ) {
// Blobs generated by MediaWiki < 1.5 on PHP 4 were serialized with the

View file

@ -62,6 +62,7 @@ class HistoryBlobCurStub {
}
}
// @phan-suppress-next-next-line PhanImpossibleCondition
// phpcs:ignore Generic.CodeAnalysis.UnconditionalIfStatement.Found
if ( false ) {
// Blobs generated by MediaWiki < 1.5 on PHP 4 were serialized with the

View file

@ -143,6 +143,7 @@ class HistoryBlobStub {
}
}
// @phan-suppress-next-next-line PhanImpossibleCondition
// phpcs:ignore Generic.CodeAnalysis.UnconditionalIfStatement.Found
if ( false ) {
// Blobs generated by MediaWiki < 1.5 on PHP 4 were serialized with the

View file

@ -1519,7 +1519,7 @@ abstract class Installer {
$data = $registry->readFromQueue( $queue );
$wgAutoloadClasses += $data['globals']['wgAutoloadClasses'];
// @phan-suppress-next-line PhanUndeclaredVariable $wgHooks is set by DefaultSettings
// @phan-suppress-next-line PhanUndeclaredVariable,PhanCoalescingAlwaysNull $wgHooks is set by DefaultSettings
$hooksWeWant = $wgHooks['LoadExtensionSchemaUpdates'] ?? [];
if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {

View file

@ -145,6 +145,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
if ( $params['serializer'] === 'php' ) {
$options[Memcached::OPT_SERIALIZER] = Memcached::SERIALIZER_PHP;
} elseif ( $params['serializer'] === 'igbinary' ) {
// @phan-suppress-next-line PhanImpossibleCondition
if ( !Memcached::HAVE_IGBINARY ) {
throw new RuntimeException(
__CLASS__ . ': the igbinary extension is not available ' .

View file

@ -3931,6 +3931,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
}
}
}
// @phan-suppress-next-line PhanImpossibleConditionInLoop
} while ( count( $this->trxIdleCallbacks ) );
if ( $e instanceof Throwable ) {
@ -3967,6 +3968,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
$e = $e ?: $ex;
}
}
// @phan-suppress-next-line PhanImpossibleConditionInLoop
} while ( count( $this->trxPreCommitCallbacks ) );
if ( $e instanceof Throwable ) {
@ -4006,6 +4008,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
$notCancelled[] = $entry;
}
}
// @phan-suppress-next-line PhanImpossibleConditionInLoop
} while ( count( $this->trxSectionCancelCallbacks ) );
$this->trxSectionCancelCallbacks = $notCancelled;

View file

@ -164,6 +164,8 @@ abstract class DatabaseMysqlBase extends Database {
$set[] = $this->addIdentifierQuotes( $var ) . ' = ' . $val;
}
// @phan-suppress-next-next-line PhanRedundantCondition
// If kept for safety and to avoid broken query
if ( $set ) {
$this->query(
'SET ' . implode( ', ', $set ),

View file

@ -418,6 +418,7 @@ abstract class LBFactory implements ILBFactory {
'ifWritesSince' => null
];
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $opts['domain'] === false && isset( $opts['wiki'] ) ) {
$opts['domain'] = $opts['wiki']; // b/c
}
@ -425,6 +426,7 @@ abstract class LBFactory implements ILBFactory {
// Figure out which clusters need to be checked
/** @var ILoadBalancer[] $lbs */
$lbs = [];
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $opts['cluster'] !== false ) {
$lbs[] = $this->getExternalLB( $opts['cluster'] );
} elseif ( $opts['domain'] !== false ) {
@ -450,6 +452,7 @@ abstract class LBFactory implements ILBFactory {
!$lb->hasStreamingReplicaServers() ||
// No writes since the last replication wait
(
// @phan-suppress-next-line PhanImpossibleConditionInLoop
$opts['ifWritesSince'] &&
$lb->lastMasterChangeTimestamp() < $opts['ifWritesSince']
)

View file

@ -117,6 +117,7 @@ class VirtualRESTServiceClient {
usort( $matches, $cmpFunc );
// Return the most specific prefix and corresponding service
// @phan-suppress-next-line PhanRedundantCondition
return $matches
? [ $matches[0], $this->getInstance( $matches[0] ) ]
: [ null, null ];

View file

@ -257,6 +257,7 @@ class BlockLogFormatter extends LogFormatter {
];
if ( !is_array( $params['6:array:flags'] ) ) {
// @phan-suppress-next-line PhanSuspiciousValueComparison
$params['6:array:flags'] = $params['6:array:flags'] === ''
? []
: explode( ',', $params['6:array:flags'] );

View file

@ -663,6 +663,7 @@ class LogEventsList extends ContextSource {
$extraUrlParams = $param['extraUrlParams'];
$useRequestParams = $param['useRequestParams'];
// @phan-suppress-next-line PhanRedundantCondition
if ( !is_array( $msgKey ) ) {
$msgKey = [ $msgKey ];
}
@ -694,6 +695,7 @@ class LogEventsList extends ContextSource {
$pager->setOffset( $param['offset'] );
}
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $lim > 0 ) {
$pager->mLimit = $lim;
}
@ -714,6 +716,7 @@ class LogEventsList extends ContextSource {
'lang' => $lang,
] );
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( count( $msgKey ) == 1 ) {
$s .= $context->msg( $msgKey[0] )->parseAsBlock();
} else { // Process additional arguments
@ -753,6 +756,7 @@ class LogEventsList extends ContextSource {
$urlParam['type'] = $types[0];
}
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $extraUrlParams !== false ) {
$urlParam = array_merge( $urlParam, $extraUrlParams );
}
@ -769,6 +773,7 @@ class LogEventsList extends ContextSource {
$s .= '</div>';
}
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $wrap != '' ) { // Wrap message in html
$s = str_replace( '$1', $s, $wrap );
}

View file

@ -311,11 +311,14 @@ class PPFrame_Hash implements PPFrame {
[ 'attr' => null, 'inner' => null, 'close' => null ];
if ( $flags & PPFrame::NO_TAGS ) {
$s = '<' . $bits['name']->getFirstChild()->value;
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
if ( $bits['attr'] ) {
$s .= $bits['attr']->getFirstChild()->value;
}
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
if ( $bits['inner'] ) {
$s .= '>' . $bits['inner']->getFirstChild()->value;
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
if ( $bits['close'] ) {
$s .= $bits['close']->getFirstChild()->value;
}

View file

@ -2975,6 +2975,7 @@ class Parser {
$profileSection = null; // profile templates
# SUBST
// @phan-suppress-next-line PhanRedundantCondition
if ( !$found ) {
$substMatch = $this->mSubstWords->matchStartAndRemove( $part1 );
@ -5323,9 +5324,11 @@ class Parser {
}
# Process alignment parameters
// @phan-suppress-next-line PhanImpossibleCondition
if ( $params['horizAlign'] ) {
$params['frame']['align'] = key( $params['horizAlign'] );
}
// @phan-suppress-next-line PhanImpossibleCondition
if ( $params['vertAlign'] ) {
$params['frame']['valign'] = key( $params['vertAlign'] );
}

View file

@ -730,7 +730,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
*/
protected static function collateFilePathListByOption( array $list, $option, $default ) {
$collatedFiles = [];
foreach ( (array)$list as $key => $value ) {
foreach ( $list as $key => $value ) {
if ( is_int( $key ) ) {
// File name as the value
if ( !isset( $collatedFiles[$default] ) ) {

View file

@ -198,7 +198,7 @@ class Command {
* @return $this
*/
public function input( ?string $inputString ): Command {
$this->inputString = $inputString === null ? null : (string)$inputString;
$this->inputString = $inputString;
return $this;
}
@ -534,6 +534,7 @@ class Command {
$this->logger->warning( "$logMsg: {command}", [ 'command' => $cmd ] );
}
// @phan-suppress-next-line PhanImpossibleCondition
if ( $buffers[2] && $this->doLogStderr ) {
$this->logger->error( "Error running {command}: {error}", [
'command' => $cmd,

View file

@ -425,7 +425,9 @@ class SpecialBlock extends FormSpecialPage {
$fields['NamespaceRestrictions']['default'] = implode( "\n", $namespaceRestrictions );
if (
// @phan-suppress-next-line PhanImpossibleCondition
empty( $pageRestrictions ) &&
// @phan-suppress-next-line PhanImpossibleCondition
empty( $namespaceRestrictions )
) {
$fields['Editing']['default'] = false;

View file

@ -119,7 +119,9 @@ class SpecialCreateAccount extends LoginSignupSpecialPage {
$this->getHookRunner()->onAddNewAccount( $user, $byEmail );
$out = $this->getOutput();
// @phan-suppress-next-line PhanImpossibleCondition
$out->setPageTitle( $this->msg( $byEmail ? 'accmailtitle' : 'accountcreated' ) );
// @phan-suppress-next-line PhanImpossibleCondition
if ( $byEmail ) {
$out->addWikiMsg( 'accmailtext', $user->getName(), $user->getEmail() );
} else {

View file

@ -284,6 +284,7 @@ class SpecialListGroupRights extends SpecialPage {
}
}
// @phan-suppress-next-line PhanImpossibleCondition
if ( empty( $r ) ) {
return '';
} else {

View file

@ -572,6 +572,7 @@ class SpecialSearch extends SpecialPage {
$this->getHookRunner()->onSpecialSearchCreateLink( $title, $params );
// Extensions using the hook might still return an empty $messageName
// @phan-suppress-next-line PhanRedundantCondition Set by hook
if ( $messageName ) {
$this->getOutput()->wrapWikiMsg( "<p class=\"$linkClass\">\n$1</p>", $params );
} else {

View file

@ -784,6 +784,7 @@ class User implements IDBAccessObject, UserIdentity {
if ( !$row ) {
// No user. Create it?
// @phan-suppress-next-line PhanImpossibleCondition
if ( !$options['create'] ) {
// No.
return null;
@ -832,6 +833,7 @@ class User implements IDBAccessObject, UserIdentity {
if ( !$user->isSystemUser() ) {
// User exists. Steal it?
// @phan-suppress-next-line PhanRedundantCondition
if ( !$options['steal'] ) {
return null;
}

View file

@ -108,7 +108,7 @@ class UserEditTracker {
[ 'user_editcount' => $count ],
[
'user_id' => $user->getId(),
'user_editcount IS NULL OR user_editcount < ' . (int)$count
'user_editcount IS NULL OR user_editcount < ' . $count
],
__METHOD__
);

View file

@ -1872,8 +1872,8 @@ class Language {
* @return string
*/
private static function hebrewYearStart( $year ) {
$a = intval( ( 12 * ( $year - 1 ) + 17 ) % 19 );
$b = intval( ( $year - 1 ) % 4 );
$a = ( 12 * ( $year - 1 ) + 17 ) % 19;
$b = ( $year - 1 ) % 4;
$m = 32.044093161144 + 1.5542417966212 * $a + $b / 4.0 - 0.0031777940220923 * ( $year - 1 );
if ( $m < 0 ) {
$m--;
@ -1884,7 +1884,7 @@ class Language {
}
$m -= $Mar;
$c = intval( ( $Mar + 3 * ( $year - 1 ) + 5 * $b + 5 ) % 7 );
$c = ( $Mar + 3 * ( $year - 1 ) + 5 * $b + 5 ) % 7;
if ( $c == 0 && $a > 11 && $m >= 0.89772376543210 ) {
$Mar++;
} elseif ( $c == 1 && $a > 6 && $m >= 0.63287037037037 ) {
@ -2171,6 +2171,7 @@ class Language {
}
}
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $data[0] == 'System' || $tz == '' ) {
# Global offset in minutes.
$minDiff = $wgLocalTZoffset;
@ -3794,6 +3795,7 @@ class Language {
if ( $tagType == 0 && $lastCh != '/' ) {
$openTags[] = $tag; // tag opened (didn't close itself)
} elseif ( $tagType == 1 ) {
// @phan-suppress-next-line PhanRedundantCondition
if ( $openTags && $tag == $openTags[count( $openTags ) - 1] ) {
array_pop( $openTags ); // tag closed
}

View file

@ -739,12 +739,13 @@ abstract class LanguageConverter implements ILanguageConverter {
$out = '';
$length = strlen( $text );
$shouldConvert = !$this->guessVariant( $text, $variant );
$continue = 1;
$continue = true;
$noScript = '<script.*?>.*?<\/script>(*SKIP)(*FAIL)';
$noStyle = '<style.*?>.*?<\/style>(*SKIP)(*FAIL)';
// phpcs:ignore Generic.Files.LineLength
$noHtml = '<(?:[^>=]*+(?>[^>=]*+=\s*+(?:"[^"]*"|\'[^\']*\'|[^\'">\s]*+))*+[^>=]*+>|.*+)(*SKIP)(*FAIL)';
// @phan-suppress-next-line PhanRedundantConditionInLoop
while ( $startPos < $length && $continue ) {
$continue = preg_match(
// Only match -{ outside of html.

View file

@ -46,6 +46,7 @@ class BenchIfSwitch extends Benchmarker {
/**
* bench function 1
* @suppress PhanSuspiciousValueComparison
*/
protected function doElseIf() {
$a = 'z';

View file

@ -57,7 +57,7 @@ class CleanupBlocks extends Maintenance {
'ipblocks',
[ 'ipb_user' ],
[
"ipb_user >= " . (int)$from,
"ipb_user >= " . $from,
"ipb_user <= " . (int)$to,
],
__METHOD__,
@ -131,7 +131,7 @@ class CleanupBlocks extends Maintenance {
[ 'ipb_id', 'user_name' ],
[
'ipb_user = user_id',
"ipb_user >= " . (int)$from,
"ipb_user >= " . $from,
"ipb_user <= " . (int)$to,
'ipb_address != user_name',
],

View file

@ -34,10 +34,12 @@ if ( !defined( 'RUN_MAINTENANCE_IF_MAIN' ) ) {
// Wasn't included from the file scope, halt execution (probably wanted the class)
// If a class is using commandLine.inc (old school maintenance), they definitely
// cannot be included and will proceed with execution
// @phan-suppress-next-line PhanSuspiciousValueComparisonInGlobalScope
if ( !Maintenance::shouldExecute() && $maintClass != CommandLineInc::class ) {
return;
}
// @phan-suppress-next-line PhanImpossibleConditionInGlobalScope
if ( !$maintClass || !class_exists( $maintClass ) ) {
echo "\$maintClass is not set or is set to a non-existent class.\n";
exit( 1 );

View file

@ -113,6 +113,7 @@ class GenerateJsonI18n extends Maintenance {
include $phpfile;
$phpfileContents = file_get_contents( $phpfile );
// @phan-suppress-next-line PhanImpossibleCondition Set by include of php file
if ( !isset( $messages ) ) {
$this->fatalError( "PHP file $phpfile does not define \$messages array" );
}

View file

@ -1602,6 +1602,7 @@ abstract class Maintenance {
$encCommand = Shell::escape( $command );
$line = Shell::escape( "$bash -c $encCommand", $retval, [], [ 'walltime' => 0 ] );
// @phan-suppress-next-line PhanImpossibleCondition,PhanSuspiciousValueComparison
if ( $retval == 0 ) {
return $line;
} elseif ( $retval == 127 ) {

View file

@ -599,6 +599,7 @@ TEXT
// for plausibility failed)
// Trying to get prefetch, if it has not been tried before
// @phan-suppress-next-line PhanSuspiciousValueComparisonInLoop
if ( $text === false && isset( $this->prefetch ) && $prefetchNotTried ) {
$prefetchNotTried = false;
$tryIsPrefetch = true;

View file

@ -49,6 +49,7 @@ class DatabaseLag extends Maintenance {
}
$this->output( "\n" );
// @phan-suppress-next-line PhanInfiniteLoop
while ( 1 ) {
$lags = $lb->getLagTimes();
unset( $lags[0] );

View file

@ -66,6 +66,7 @@ class PPFuzzTester {
}
$overallStart = microtime( true );
$reportInterval = 1000;
// @phan-suppress-next-line PhanInfiniteLoop
for ( $i = 1; true; $i++ ) {
$t = -microtime( true );
try {

View file

@ -391,6 +391,7 @@ class RebuildRecentchanges extends Maintenance {
->getGroupsWithPermission( 'autopatrol' ) : [];
# Flag our recent bot edits
// @phan-suppress-next-line PhanRedundantCondition
if ( $botgroups ) {
$this->output( "Flagging bot account edits...\n" );

View file

@ -360,12 +360,14 @@ class CheckStorage {
print "\n\nErrors:\n";
foreach ( $this->errors as $name => $errors ) {
// @phan-suppress-next-line PhanImpossibleConditionInLoop
if ( count( $errors ) ) {
$description = $this->errorDescriptions[$name];
echo "$description: " . implode( ',', array_keys( $errors ) ) . "\n";
}
}
// @phan-suppress-next-line PhanImpossibleCondition
if ( count( $this->errors['restore text'] ) && $fix ) {
if ( (string)$xml !== '' ) {
$this->restoreText( array_keys( $this->errors['restore text'] ), $xml );

View file

@ -139,6 +139,7 @@ class UserDupes {
$this->out( "\n" );
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $this->reassigned > 0 ) {
if ( $doDelete ) {
$this->out( "$this->reassigned duplicate accounts had edits "
@ -148,6 +149,7 @@ class UserDupes {
}
}
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $this->trimmed > 0 ) {
if ( $doDelete ) {
$this->out(
@ -160,12 +162,14 @@ class UserDupes {
}
}
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $this->failed > 0 ) {
$this->out( "Something terribly awry; $this->failed duplicate accounts were not removed.\n" );
return false;
}
// @phan-suppress-next-line PhanSuspiciousValueComparison
if ( $this->trimmed == 0 || $doDelete ) {
$this->out( "It is now safe to apply the unique index on user_name.\n" );