* @ingroup API
*/
class ApiMain extends ApiBase {
-
/**
* When no format parameter is given, this format will be used
*/
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'
+ ),
) );
}
* @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
* @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' );
}
$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'];
$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() ) );
$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'] ) ) {
} 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'] ) ) {
' (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 ' .
$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;
$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;
}
$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 );
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"',
);
}
// 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;
$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'] );
$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 );
}
$this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
}
-
if ( !$status->isOK() ) {
if ( $compatibilityMode ) {
$this->dieStatus( $status );
* @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();
* 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 ) {
/**
* Return the next in a sequence, save the value for retrieval via insertId()
- *
+ *
* @param string $seqName
* @return int|null
*/
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';
}
}
// 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
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";
* @since 1.17
*/
class MysqlUpdater extends DatabaseUpdater {
-
protected function getCoreUpdateList() {
return array(
array( 'disableContentHandlerUseDB' ),
// 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' ),
);
}
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(
// 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' ),
);