Fix CodeSniffer errors and warnings

Change-Id: Idc74e34634d88625773fb8f73315f61edfa67e28
This commit is contained in:
Siebrand Mazeland 2014-02-05 11:20:17 +01:00
parent 1baaa740ba
commit 0cef781886
18 changed files with 97 additions and 35 deletions

View file

@ -39,7 +39,6 @@
* @ingroup API
*/
class ApiMain extends ApiBase {
/**
* When no format parameter is given, this format will be used
*/
@ -1148,7 +1147,10 @@ class ApiMain extends ApiBase {
array( 'code' => 'maxlag', 'info' => 'Waiting for host: x seconds lagged' ),
array( 'code' => 'maxlag', 'info' => 'Waiting for a database server: x seconds lagged' ),
array( 'code' => 'assertuserfailed', 'info' => 'Assertion that the user is logged in failed' ),
array( 'code' => 'assertbotfailed', 'info' => 'Assertion that the user has the bot right failed' ),
array(
'code' => 'assertbotfailed',
'info' => 'Assertion that the user has the bot right failed'
),
) );
}

View file

@ -39,7 +39,6 @@
* @since 1.21 derives from ApiBase instead of ApiQueryBase
*/
class ApiPageSet extends ApiBase {
/**
* Constructor flag: The new instance of ApiPageSet will ignore the 'generator=' parameter
* @since 1.21
@ -536,7 +535,9 @@ class ApiPageSet extends ApiBase {
* @return array Array suitable for inclusion in the response
* @since 1.23
*/
public function getInvalidTitlesAndRevisions( $invalidChecks = array( 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles' ) ) {
public function getInvalidTitlesAndRevisions( $invalidChecks = array( 'invalidTitles',
'special', 'missingIds', 'missingRevIds', 'missingTitles', 'interwikiTitles' )
) {
$result = array();
if ( in_array( "invalidTitles", $invalidChecks ) ) {
self::addValues( $result, $this->getInvalidTitles(), 'invalid', 'title' );

View file

@ -67,8 +67,12 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
}
$dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
$from = ( $params['from'] === null ? null : $this->titlePartToKey( $params['from'], NS_CATEGORY ) );
$to = ( $params['to'] === null ? null : $this->titlePartToKey( $params['to'], NS_CATEGORY ) );
$from = ( $params['from'] === null
? null
: $this->titlePartToKey( $params['from'], NS_CATEGORY ) );
$to = ( $params['to'] === null
? null
: $this->titlePartToKey( $params['to'], NS_CATEGORY ) );
$this->addWhereRange( 'cat_title', $dir, $from, $to );
$min = $params['min'];

View file

@ -154,7 +154,6 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
$this->titlePartToKey( $params['to'], $params['namespace'] ) );
$this->addWhereRange( $pfx . $fieldTitle, 'newer', $from, $to );
if ( isset( $params['prefix'] ) ) {
$this->addWhere( $pfx . $fieldTitle . $db->buildLike( $this->titlePartToKey(
$params['prefix'], $params['namespace'] ), $db->anyString() ) );

View file

@ -87,8 +87,12 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
$this->addWhereFld( 'page_namespace', $params['namespace'] );
$dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
$from = ( $params['from'] === null ? null : $this->titlePartToKey( $params['from'], $params['namespace'] ) );
$to = ( $params['to'] === null ? null : $this->titlePartToKey( $params['to'], $params['namespace'] ) );
$from = ( $params['from'] === null
? null
: $this->titlePartToKey( $params['from'], $params['namespace'] ) );
$to = ( $params['to'] === null
? null
: $this->titlePartToKey( $params['to'], $params['namespace'] ) );
$this->addWhereRange( 'page_title', $dir, $from, $to );
if ( isset( $params['prefix'] ) ) {

View file

@ -176,8 +176,12 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
} elseif ( $mode == 'all' ) {
$this->addWhereFld( 'ar_namespace', $params['namespace'] );
$from = $params['from'] === null ? null : $this->titlePartToKey( $params['from'], $params['namespace'] );
$to = $params['to'] === null ? null : $this->titlePartToKey( $params['to'], $params['namespace'] );
$from = $params['from'] === null
? null
: $this->titlePartToKey( $params['from'], $params['namespace'] );
$to = $params['to'] === null
? null
: $this->titlePartToKey( $params['to'], $params['namespace'] );
$this->addWhereRange( 'ar_title', $dir, $from, $to );
if ( isset( $params['prefix'] ) ) {

View file

@ -677,7 +677,8 @@ class ApiQueryImageInfo extends ApiQueryBase {
' (requires url and param ' . $modulePrefix . 'urlwidth)',
'mediatype' => ' mediatype - Adds the media type of the image',
'metadata' => ' metadata - Lists Exif metadata for the version of the image',
'commonmetadata' => ' commonmetadata - Lists file format generic metadata for the version of the image',
'commonmetadata' => ' commonmetadata - Lists file format generic metadata ' .
'for the version of the image',
'extmetadata' => ' extmetadata - Lists formatted metadata combined ' .
'from multiple sources. Results are HTML formatted.',
'archivename' => ' archivename - Adds the file name of the archive ' .

View file

@ -573,12 +573,20 @@ class ApiQuerySiteinfo extends ApiQueryBase {
$ret['vcs-url'] = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : '';
}
}
if ( SpecialVersion::getExtLicenseFileName( $extensionPath ) ) {
$ret['license-name'] = isset( $ext['license-name'] ) ? $ext['license-name'] : '';
$ret['license'] = SpecialPage::getTitleFor( 'Version', "License/{$ext['name']}" )->getLinkURL();
$ret['license'] = SpecialPage::getTitleFor(
'Version',
"License/{$ext['name']}"
)->getLinkURL();
}
if ( SpecialVersion::getExtAuthorsFileName( $extensionPath ) ) {
$ret['credits'] = SpecialPage::getTitleFor( 'Version', "Credits/{$ext['name']}" )->getLinkURL();
$ret['credits'] = SpecialPage::getTitleFor(
'Version',
"Credits/{$ext['name']}"
)->getLinkURL();
}
}
$data[] = $ret;

View file

@ -360,7 +360,13 @@ class ApiQueryContributions extends ApiQueryBase {
$vals['commenthidden'] = '';
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->rev_deleted, Revision::DELETED_COMMENT, $this->getUser() ) ) {
$userCanView = Revision::userCanBitfield(
$row->rev_deleted,
Revision::DELETED_COMMENT, $this->getUser()
);
if ( $userCanView ) {
if ( $this->fld_comment ) {
$vals['comment'] = $row->rev_comment;
}

View file

@ -97,14 +97,19 @@ class ApiRevisionDelete extends ApiBase {
$data = $this->extractStatusInfo( $status );
$data['target'] = $targetObj->getFullText();
$data['items'] = array();
foreach ( $status->itemStatuses as $id => $s ) {
$data['items'][$id] = $this->extractStatusInfo( $s );
$data['items'][$id]['id'] = $id;
}
$list->reloadFromMaster();
// @codingStandardsIgnoreStart Avoid function calls in a FOR loop test part
for ( $item = $list->reset(); $list->current(); $item = $list->next() ) {
$data['items'][$item->getId()] += $item->getApiData( $this->getResult() );
}
// @codingStandardsIgnoreEnd
$data['items'] = array_values( $data['items'] );
$result->setIndexedTagName( $data['items'], 'i' );
$result->addValue( null, $this->getModuleName(), $data );
@ -232,10 +237,12 @@ class ApiRevisionDelete extends ApiBase {
public function getExamples() {
return array(
'api.php?action=revisiondelete&target=Main%20Page&type=revision&ids=12345&hide=content&token=123ABC'
=> 'Hide content for revision 12345 on the Main Page',
'api.php?action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&reason=BLP%20violation&token=123ABC'
=> 'Hide all data on log entry 67890 with the reason "BLP violation"',
'api.php?action=revisiondelete&target=Main%20Page&type=revision&ids=12345&' .
'hide=content&token=123ABC'
=> 'Hide content for revision 12345 on the Main Page',
'api.php?action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&' .
'reason=BLP%20violation&token=123ABC'
=> 'Hide all data on log entry 67890 with the reason "BLP violation"',
);
}

View file

@ -48,12 +48,20 @@ class ApiWatch extends ApiBase {
// title is still supported for backward compatibility
if ( !isset( $params['title'] ) ) {
$pageSet->execute();
$res = $pageSet->getInvalidTitlesAndRevisions( array( 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'interwikiTitles' ) );
$res = $pageSet->getInvalidTitlesAndRevisions( array(
'invalidTitles',
'special',
'missingIds',
'missingRevIds',
'interwikiTitles'
) );
foreach ( $pageSet->getMissingTitles() as $title ) {
$r = $this->watchTitle( $title, $user, $params );
$r['missing'] = 1;
$res[] = $r;
}
foreach ( $pageSet->getGoodTitles() as $title ) {
$r = $this->watchTitle( $title, $user, $params );
$res[] = $r;
@ -64,9 +72,13 @@ class ApiWatch extends ApiBase {
$extraParams = array_keys( array_filter( $pageSet->extractRequestParams(), function ( $x ) {
return $x !== null && $x !== false;
} ) );
if ( $extraParams ) {
$p = $this->getModulePrefix();
$this->dieUsage( "The parameter {$p}title can not be used with ". implode( ", ", $extraParams ), 'invalidparammix' );
$this->dieUsage(
"The parameter {$p}title can not be used with " . implode( ", ", $extraParams ),
'invalidparammix'
);
}
$title = Title::newFromText( $params['title'] );
@ -78,7 +90,9 @@ class ApiWatch extends ApiBase {
$this->getResult()->addValue( null, $this->getModuleName(), $res );
}
private function watchTitle( Title $title, User $user, array $params, $compatibilityMode = false ) {
private function watchTitle( Title $title, User $user, array $params,
$compatibilityMode = false
) {
if ( !$title->isWatchable() ) {
return array( 'title' => $title->getPrefixedText(), 'watchable' => 0 );
}
@ -116,7 +130,6 @@ class ApiWatch extends ApiBase {
$this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
}
if ( !$status->isOK() ) {
if ( $compatibilityMode ) {
$this->dieStatus( $status );

View file

@ -984,7 +984,9 @@ class DatabaseMssql extends DatabaseBase {
* @param array $join_conds
* @return string
*/
protected function tableNamesWithUseIndexOrJOIN( $tables, $use_index = array(), $join_conds = array() ) {
protected function tableNamesWithUseIndexOrJOIN( $tables, $use_index = array(),
$join_conds = array()
) {
$ret = array();
$retJOIN = array();
$use_index_safe = is_array( $use_index ) ? $use_index : array();

View file

@ -827,7 +827,9 @@ __INDEXATTR__;
* can be locked. That means tables in an outer join cannot be FOR UPDATE locked. Trying to do
* so causes a DB error. This wrapper checks which tables can be locked and adjusts it accordingly.
*/
function selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array() ) {
function selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__,
$options = array(), $join_conds = array()
) {
if ( is_array( $options ) ) {
$forUpdateKey = array_search( 'FOR UPDATE', $options );
if ( $forUpdateKey !== false && $join_conds ) {
@ -1063,7 +1065,7 @@ __INDEXATTR__;
/**
* Return the next in a sequence, save the value for retrieval via insertId()
*
*
* @param string $seqName
* @return int|null
*/
@ -1564,7 +1566,7 @@ SQL;
if ( isset( $options['FOR UPDATE'] ) ) {
$postLimitTail .= ' FOR UPDATE OF ' . implode( ', ', $options['FOR UPDATE'] );
} else if ( isset( $noKeyOptions['FOR UPDATE'] ) ) {
} elseif ( isset( $noKeyOptions['FOR UPDATE'] ) ) {
$postLimitTail .= ' FOR UPDATE';
}

View file

@ -1218,7 +1218,8 @@ class SwiftFileBackend extends FileBackendStore {
}
// Run all requests for the first stage, then the next, and so on
for ( $stage = 0; $stage < count( $httpReqsByStage ); ++$stage ) {
$reqCount = count( $httpReqsByStage );
for ( $stage = 0; $stage < $reqCount; ++$stage ) {
$httpReqs = $this->http->runMulti( $httpReqsByStage[$stage] );
foreach ( $httpReqs as $index => $httpReq ) {
// Run the callback for each request of this operation

View file

@ -812,8 +812,14 @@ class HTMLForm extends ContextSource {
if ( $this->isVForm() ) {
// mw-ui-block is necessary because the buttons aren't necessarily in an
// immediate child div of the vform.
// TODO Let client specify if the primary submit button is progressive or destructive
array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-big', 'mw-ui-constructive', 'mw-ui-block' );
// @todo Let client specify if the primary submit button is progressive or destructive
array_push(
$attribs['class'],
'mw-ui-button',
'mw-ui-big',
'mw-ui-constructive',
'mw-ui-block'
);
}
$html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";

View file

@ -28,7 +28,6 @@
* @since 1.17
*/
class MysqlUpdater extends DatabaseUpdater {
protected function getCoreUpdateList() {
return array(
array( 'disableContentHandlerUseDB' ),
@ -246,8 +245,9 @@ class MysqlUpdater extends DatabaseUpdater {
// 1.23
array( 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ),
array( 'addIndex', 'logging', 'log_user_text_type_time', 'patch-logging_user_text_type_time_index.sql' ),
array( 'addIndex', 'logging', 'log_user_text_time', 'patch-logging_user_text_time_index.sql' ),
array( 'addIndex', 'logging', 'log_user_text_type_time',
'patch-logging_user_text_type_time_index.sql' ),
array( 'addIndex', 'logging', 'log_user_text_time', 'patch-logging_user_text_time_index.sql' ),
array( 'addField', 'page', 'page_links_updated', 'patch-page_links_updated.sql' ),
);
}

View file

@ -260,7 +260,8 @@ class PostgresUpdater extends DatabaseUpdater {
array( 'addPgIndex', 'job', 'job_cmd_token', '(job_cmd, job_token, job_random)' ),
array( 'addPgIndex', 'job', 'job_cmd_token_id', '(job_cmd, job_token, job_id)' ),
array( 'addPgIndex', 'filearchive', 'fa_sha1', '(fa_sha1)' ),
array( 'addPgIndex', 'logging', 'logging_user_text_type_time', '(log_user_text, log_type, log_timestamp)' ),
array( 'addPgIndex', 'logging', 'logging_user_text_type_time',
'(log_user_text, log_type, log_timestamp)' ),
array( 'addPgIndex', 'logging', 'logging_user_text_time', '(log_user_text, log_timestamp)' ),
array( 'checkIndex', 'pagelink_unique', array(

View file

@ -123,7 +123,8 @@ class SqliteUpdater extends DatabaseUpdater {
// 1.23
array( 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ),
array( 'addIndex', 'logging', 'log_user_text_type_time', 'patch-logging_user_text_type_time_index.sql' ),
array( 'addIndex', 'logging', 'log_user_text_type_time',
'patch-logging_user_text_type_time_index.sql' ),
array( 'addIndex', 'logging', 'log_user_text_time', 'patch-logging_user_text_time_index.sql' ),
array( 'addField', 'page', 'page_links_updated', 'patch-page_links_updated.sql' ),
);