Merge "Remove unreachable code after exception/die/exit"
This commit is contained in:
commit
c574766a8a
8 changed files with 10 additions and 21 deletions
|
|
@ -124,7 +124,6 @@ if ( !interface_exists( LoggerInterface::class ) ) {
|
|||
);
|
||||
echo $message;
|
||||
trigger_error( $message, E_USER_ERROR );
|
||||
die( 1 );
|
||||
}
|
||||
|
||||
HeaderCallback::register();
|
||||
|
|
|
|||
|
|
@ -648,31 +648,30 @@ class ApiUpload extends ApiBase {
|
|||
// Recoverable errors
|
||||
case UploadBase::MIN_LENGTH_PARTNAME:
|
||||
$this->dieRecoverableError( [ 'filename-tooshort' ], 'filename' );
|
||||
break;
|
||||
// dieRecoverableError prevents continuation
|
||||
case UploadBase::ILLEGAL_FILENAME:
|
||||
$this->dieRecoverableError(
|
||||
[ ApiMessage::create(
|
||||
'illegal-filename', null, [ 'filename' => $verification['filtered'] ]
|
||||
) ], 'filename'
|
||||
);
|
||||
break;
|
||||
// dieRecoverableError prevents continuation
|
||||
case UploadBase::FILENAME_TOO_LONG:
|
||||
$this->dieRecoverableError( [ 'filename-toolong' ], 'filename' );
|
||||
break;
|
||||
// dieRecoverableError prevents continuation
|
||||
case UploadBase::FILETYPE_MISSING:
|
||||
$this->dieRecoverableError( [ 'filetype-missing' ], 'filename' );
|
||||
break;
|
||||
// dieRecoverableError prevents continuation
|
||||
case UploadBase::WINDOWS_NONASCII_FILENAME:
|
||||
$this->dieRecoverableError( [ 'windows-nonascii-filename' ], 'filename' );
|
||||
break;
|
||||
|
||||
// Unrecoverable errors
|
||||
case UploadBase::EMPTY_FILE:
|
||||
$this->dieWithError( 'empty-file' );
|
||||
break;
|
||||
// dieWithError prevents continuation
|
||||
case UploadBase::FILE_TOO_LARGE:
|
||||
$this->dieWithError( 'file-too-large' );
|
||||
break;
|
||||
// dieWithError prevents continuation
|
||||
|
||||
case UploadBase::FILETYPE_BADTYPE:
|
||||
$extradata = [
|
||||
|
|
@ -700,7 +699,7 @@ class ApiUpload extends ApiBase {
|
|||
}
|
||||
|
||||
$this->dieWithError( $msg, 'filetype-banned', $extradata );
|
||||
break;
|
||||
// dieWithError prevents continuation
|
||||
|
||||
case UploadBase::VERIFICATION_ERROR:
|
||||
$msg = ApiMessage::create( $verification['details'], 'verification-error' );
|
||||
|
|
@ -713,16 +712,15 @@ class ApiUpload extends ApiBase {
|
|||
$msg->setApiData( $msg->getApiData() + [ 'details' => $details ] );
|
||||
// @phan-suppress-next-line PhanTypeMismatchArgument
|
||||
$this->dieWithError( $msg );
|
||||
break;
|
||||
// dieWithError prevents continuation
|
||||
|
||||
case UploadBase::HOOK_ABORTED:
|
||||
$msg = $verification['error'] === '' ? 'hookaborted' : $verification['error'];
|
||||
$this->dieWithError( $msg, 'hookaborted', [ 'details' => $verification['error'] ] );
|
||||
break;
|
||||
// dieWithError prevents continuation
|
||||
default:
|
||||
$this->dieWithError( 'apierror-unknownerror-nocode', 'unknown-error',
|
||||
[ 'details' => [ 'code' => $verification['status'] ] ] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -521,7 +521,6 @@ class LoadBalancer implements ILoadBalancer {
|
|||
$this->lastError = 'Unknown error'; // set here in case of worse failure
|
||||
$this->lastError = 'No working replica DB server: ' . $this->lastError;
|
||||
$this->reportConnectionError();
|
||||
return null; // unreachable due to exception
|
||||
}
|
||||
|
||||
return $i;
|
||||
|
|
@ -1601,7 +1600,6 @@ class LoadBalancer implements ILoadBalancer {
|
|||
$conn = $this->getConnection( $index, self::CONN_SILENCE_ERRORS );
|
||||
if ( !$conn ) {
|
||||
$this->reportConnectionError();
|
||||
return null; // unreachable due to exception
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ class SpinnerWidget {
|
|||
return $this->toString();
|
||||
} catch ( \Exception $ex ) {
|
||||
trigger_error( (string)$ex, E_USER_ERROR );
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ class BenchmarkCommentFormatter extends Benchmarker {
|
|||
$result = json_decode( $json, true );
|
||||
if ( !isset( $result['query']['recentchanges'] ) ) {
|
||||
$this->fatalError( "Invalid JSON data" );
|
||||
throw new \Exception( 'Invalid JSON data' ); // for phan
|
||||
}
|
||||
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable T240141
|
||||
$entries = $result['query']['recentchanges'];
|
||||
$inputs = [];
|
||||
foreach ( $entries as $entry ) {
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ class DeleteTag extends Maintenance {
|
|||
$tagId = $defStore->getId( $tag );
|
||||
} catch ( NameTableAccessException $ex ) {
|
||||
$this->fatalError( "Tag '$tag' not found" );
|
||||
// To make analyzers happy
|
||||
return;
|
||||
}
|
||||
|
||||
$status = ChangeTags::canDeleteTag( $tag, null, ChangeTags::BYPASS_MAX_USAGE_CHECK );
|
||||
|
|
|
|||
|
|
@ -323,7 +323,6 @@ TEXT
|
|||
if ( !$statusRootPage->isGood() ) {
|
||||
// Die here so that it doesn't print "Done!"
|
||||
$this->fatalError( $statusRootPage->getMessage( false, false, 'en' )->text() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ( $this->hasOption( 'skip-to' ) ) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,6 @@ class PurgeParserCache extends Maintenance {
|
|||
$timestamp = time() + $wgParserCacheExpireTime - intval( $inputAge );
|
||||
} else {
|
||||
$this->fatalError( "Must specify either --expiredate or --age" );
|
||||
return;
|
||||
}
|
||||
$this->usleep = 1e3 * $this->getOption( 'msleep', 0 );
|
||||
$this->lastTimestamp = microtime( true );
|
||||
|
|
@ -86,7 +85,6 @@ class PurgeParserCache extends Maintenance {
|
|||
$humanDate = ConvertibleTimestamp::convert( TS_RFC2822, $timestamp );
|
||||
if ( $this->hasOption( 'dry-run' ) ) {
|
||||
$this->fatalError( "\nDry run mode, would delete objects having an expiry before " . $humanDate . "\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
$this->output( "Deleting objects expiring before " . $humanDate . "\n" );
|
||||
|
|
|
|||
Loading…
Reference in a new issue