}
private $fld_ids = false, $fld_flags = false, $fld_timestamp = false, $fld_size = false, $fld_sha1 = false,
- $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
- $fld_content = false, $fld_tags = false, $fld_contentmodel = false;
+ $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
+ $fld_content = false, $fld_tags = false, $fld_contentmodel = false;
private $tokenFunctions;
'rollback' => array( 'ApiQueryRevisions', 'getRollbackToken' )
);
wfRunHooks( 'APIQueryRevisionsTokens', array( &$this->tokenFunctions ) );
+
return $this->tokenFunctions;
}
if ( !$wgUser->isAllowed( 'rollback' ) ) {
return false;
}
+
return $wgUser->getEditToken(
array( $title->getPrefixedText(), $rev->getUserText() ) );
}
// Enumerating revisions on multiple pages make it extremely
// difficult to manage continuations and require additional SQL indexes
$enumRevMode = ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ||
- !is_null( $params['limit'] ) || !is_null( $params['startid'] ) ||
- !is_null( $params['endid'] ) || $params['dir'] === 'newer' ||
- !is_null( $params['start'] ) || !is_null( $params['end'] ) );
+ !is_null( $params['limit'] ) || !is_null( $params['startid'] ) ||
+ !is_null( $params['endid'] ) || $params['dir'] === 'newer' ||
+ !is_null( $params['start'] ) || !is_null( $params['end'] ) );
$pageSet = $this->getPageSet();
$pageCount = $pageSet->getGoodTitleCount();
$params['diffto'] = 0;
}
if ( ( !ctype_digit( $params['diffto'] ) || $params['diffto'] < 0 )
- && $params['diffto'] != 'prev' && $params['diffto'] != 'next' ) {
+ && $params['diffto'] != 'prev' && $params['diffto'] != 'next'
+ ) {
$this->dieUsage( 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"', 'diffto' );
}
// Check whether the revision exists and is readable,
$this->addOption( 'ORDER BY', array(
'rev_page',
'rev_id'
- ));
+ ) );
// assumption testing -- we should never get more then $pageCount rows.
$limit = $pageCount;
$res = $this->select( __METHOD__ );
foreach ( $res as $row ) {
- if ( ++ $count > $limit ) {
+ if ( ++$count > $limit ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
if ( !$enumRevMode ) {
ApiBase::dieDebug( __METHOD__, 'Got more rows then expected' ); // bug report
$vals['parsetree'] = $xml;
} else {
$this->setWarning( "Conversion to XML is supported for wikitext only, " .
- $title->getPrefixedDBkey() .
- " uses content model " . $content->getModel() );
+ $title->getPrefixedDBkey() .
+ " uses content model " . $content->getModel() );
}
}
$name = $title->getPrefixedDBkey();
$this->dieUsage( "The requested format {$this->contentFormat} is not supported " .
- "for content model $model used by $name", 'badformat' );
+ "for content model $model used by $name", 'badformat' );
}
$text = $content->serialize( $format );
$model = $title->getContentModel();
if ( $this->contentFormat
- && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) ) {
+ && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat )
+ ) {
$name = $title->getPrefixedDBkey();
$this->dieUsage( "The requested format {$this->contentFormat} is not supported for " .
- "content model $model used by $name", 'badformat' );
+ "content model $model used by $name", 'badformat' );
}
$difftocontent = ContentHandler::makeContent( $this->difftotext, $title, $model, $this->contentFormat );
$vals['diff']['notcached'] = '';
}
}
+
return $vals;
}
// formatComment() calls wfMessage() among other things
return 'anon-public-user-private';
}
+
return 'public';
}
public function getParamDescription() {
$p = $this->getModulePrefix();
+
return array(
'prop' => array(
'Which properties to get for each revision:',
return array_merge( parent::getPossibleErrors(), array(
array( 'nosuchrevid', 'diffto' ),
array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options '
- . '(limit, startid, endid, dirNewer, start, end).' ),
+ . '(limit, startid, endid, dirNewer, start, end).' ),
array( 'code' => 'multpages', 'info' => 'titles, pageids or a generator was used to supply multiple pages, '
- . ' but the limit, startid, endid, dirNewer, user, excludeuser, '
- . 'start and end parameters may only be used on a single page.' ),
+ . ' but the limit, startid, endid, dirNewer, user, excludeuser, '
+ . 'start and end parameters may only be used on a single page.' ),
array( 'code' => 'diffto', 'info' => 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"' ),
array( 'code' => 'badparams', 'info' => 'start and startid cannot be used together' ),
array( 'code' => 'badparams', 'info' => 'end and endid cannot be used together' ),
array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ),
array( 'code' => 'nosuchsection', 'info' => 'There is no section section in rID' ),
array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied '
- . ' to the page\'s content model' ),
+ . ' to the page\'s content model' ),
) );
}
$totalhits = $matches->getTotalHits();
if ( $totalhits !== null ) {
$apiResult->addValue( array( 'query', 'searchinfo' ),
- 'totalhits', $totalhits );
+ 'totalhits', $totalhits );
}
}
if ( isset( $searchInfo['suggestion'] ) && $matches->hasSuggestion() ) {
$apiResult->addValue( array( 'query', 'searchinfo' ),
- 'suggestion', $matches->getSuggestionQuery() );
+ 'suggestion', $matches->getSuggestionQuery() );
}
// Add the search results to the result
$result = $matches->next();
while ( $result ) {
- if ( ++ $count > $limit ) {
+ if ( ++$count > $limit ) {
// We've reached the one extra which shows that there are additional items to be had. Stop here...
$this->setContinueEnumParameter( 'offset', $params['offset'] + $params['limit'] );
break;
// Add item to results and see whether it fits
$fit = $apiResult->addValue( array( 'query', $this->getModuleName() ),
- null, $vals );
+ null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'offset', $params['offset'] + $count - 1 );
break;
if ( is_null( $resultPageSet ) ) {
$apiResult->setIndexedTagName_internal( array(
- 'query', $this->getModuleName()
- ), 'p' );
+ 'query', $this->getModuleName()
+ ), 'p' );
} else {
$resultPageSet->populateFromTitles( $titles );
}
// Abuse siprop as a query-continue parameter
// and set it to all unprocessed props
$this->setContinueEnumParameter( 'prop', implode( '|',
- array_diff( $params['prop'], $done ) ) );
+ array_diff( $params['prop'], $done ) ) );
break;
}
$done[] = $p;
}
protected function appendGeneralInfo( $property ) {
- global $wgContLang,
- $wgDisableLangConversion,
- $wgDisableTitleConversion;
+ global $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion;
$data = array();
$mainPage = Title::newMainPage();
}
$this->getResult()->setIndexedTagName( $data, 'ns' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
sort( $data );
$this->getResult()->setIndexedTagName( $data, 'ns' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
}
}
$this->getResult()->setIndexedTagName( $data, 'specialpage' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
$data[] = $arr;
}
$this->getResult()->setIndexedTagName( $data, 'magicword' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
}
$this->getResult()->setIndexedTagName( $data, 'iw' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
$result = $this->getResult();
$result->setIndexedTagName( $data, 'db' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
if ( $group == 'user' ) {
$arr['number'] = SiteStats::users();
-
// '*' and autopromote groups have no size
} elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) {
$arr['number'] = SiteStats::numberInGroup( $group );
}
$result->setIndexedTagName( $data, 'group' );
+
return $result->addValue( 'query', $property, $data );
}
$data[] = array( 'ext' => $ext );
}
$this->getResult()->setIndexedTagName( $data, 'fe' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
$ret['url'] = $ext['url'];
}
if ( isset( $ext['version'] ) ) {
- $ret['version'] = $ext['version'];
+ $ret['version'] = $ext['version'];
} elseif ( isset( $ext['svn-revision'] ) &&
preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/',
- $ext['svn-revision'], $m ) )
- {
- $ret['version'] = 'r' . $m[1];
+ $ext['svn-revision'], $m )
+ ) {
+ $ret['version'] = 'r' . $m[1];
}
$data[] = $ret;
}
}
$this->getResult()->setIndexedTagName( $data, 'ext' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
$data[] = $lang;
}
$this->getResult()->setIndexedTagName( $data, 'lang' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
$data[] = $skin;
}
$this->getResult()->setIndexedTagName( $data, 'skin' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
$wgParser->firstCallInit();
$tags = array_map( array( $this, 'formatParserTags' ), $wgParser->getTags() );
$this->getResult()->setIndexedTagName( $tags, 't' );
+
return $this->getResult()->addValue( 'query', $property, $tags );
}
$wgParser->firstCallInit();
$hooks = $wgParser->getFunctionHooks();
$this->getResult()->setIndexedTagName( $hooks, 'h' );
+
return $this->getResult()->addValue( 'query', $property, $hooks );
}
public function appendVariables( $property ) {
$variables = MagicWord::getVariableIDs();
$this->getResult()->setIndexedTagName( $variables, 'v' );
+
return $this->getResult()->addValue( 'query', $property, $variables );
}
// Make a copy of the global so we don't try to set the _element key of it - bug 45130
$protocols = array_values( $wgUrlProtocols );
$this->getResult()->setIndexedTagName( $protocols, 'p' );
+
return $this->getResult()->addValue( 'query', $property, $protocols );
}
}
$this->getResult()->setIndexedTagName( $data, 'hook' );
+
return $this->getResult()->addValue( 'query', $property, $data );
}
public function getParamDescription() {
$p = $this->getModulePrefix();
+
return array(
'prop' => array(
'Which sysinfo properties to get:',
' specialpagealiases - List of special page aliases',
' magicwords - List of magic words and their aliases',
' statistics - Returns site statistics',
- " interwikimap - Returns interwiki map " .
+ ' interwikimap - Returns interwiki map ' .
"(optionally filtered, (optionally localised by using {$p}inlanguagecode))",
' dbrepllag - Returns database server with the highest replication lag',
' usergroups - Returns user groups and the associated permissions',
' extensions - Returns extensions installed on the wiki',
' fileextensions - Returns list of file extensions allowed to be uploaded',
' rightsinfo - Returns wiki rights (license) information if available',
- " languages - Returns a list of languages MediaWiki supports" .
+ ' languages - Returns a list of languages MediaWiki supports' .
"(optionally localised by using {$p}inlanguagecode)",
' skins - Returns a list of all enabled skins',
' extensiontags - Returns a list of parser extension tags',
$result->addValue( array( 'query', $this->getModuleName() ), null, $imageInfo );
$result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), $modulePrefix );
}
- //TODO: update exception handling here to understand current getFile exceptions
+ // @todo Update exception handling here to understand current getFile exceptions
} catch ( UploadStashNotAvailableException $e ) {
$this->dieUsage( "Session not available: " . $e->getMessage(), "nosession" );
} catch ( UploadStashFileNotFoundException $e ) {
*/
public function getParamDescription() {
$p = $this->getModulePrefix();
+
return array(
'prop' => self::getPropertyDescriptions( $this->propertyFilter, $p ),
'filekey' => 'Key that identifies a previous upload that was stashed temporarily.',
'api.php?action=query&prop=stashimageinfo&siifilekey=b34edoe3|bceffd4&siiurlwidth=120&siiprop=url',
);
}
-
}
private $limit;
private $fld_displayname = false, $fld_description = false,
- $fld_hitcount = false;
+ $fld_hitcount = false;
public function __construct( $query, $moduleName ) {
parent::__construct( $query, $moduleName, 'tg' );
if ( ++$count > $this->limit ) {
$this->setContinueEnumParameter( 'continue', $tagName );
+
return false;
}
$fit = $this->result->addValue( array( 'query', $this->getModuleName() ), null, $tag );
if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $tagName );
+
return false;
}
private $params, $prefixMode, $userprefix, $multiUserMode, $usernames, $parentLens;
private $fld_ids = false, $fld_title = false, $fld_timestamp = false,
- $fld_comment = false, $fld_parsedcomment = false, $fld_flags = false,
- $fld_patrolled = false, $fld_tags = false, $fld_size = false, $fld_sizediff = false;
+ $fld_comment = false, $fld_parsedcomment = false, $fld_flags = false,
+ $fld_patrolled = false, $fld_tags = false, $fld_size = false, $fld_sizediff = false;
public function execute() {
// Parse some parameters
// Fetch each row
foreach ( $res as $row ) {
- if ( ++ $count > $limit ) {
+ if ( ++$count > $limit ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
if ( $this->multiUserMode ) {
$this->setContinueEnumParameter( 'continue', $this->continueStr( $row ) );
if ( !is_null( $show ) ) {
$show = array_flip( $show );
if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
- || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) ) {
+ || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
+ ) {
$this->dieUsageMsg( 'show' );
}
) );
if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ||
- $this->fld_patrolled ) {
+ $this->fld_patrolled
+ ) {
if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) {
$this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
}
public function getParamDescription() {
global $wgRCMaxAge;
$p = $this->getModulePrefix();
+
return array(
'limit' => 'The maximum number of contributions to return',
'start' => 'The start timestamp to return from',
' tags - Lists tags for the edit',
),
'show' => array( "Show only items that meet this criteria, e.g. non minor edits only: {$p}show=!minor",
- "NOTE: if {$p}show=patrolled or {$p}show=!patrolled is set, revisions older than \$wgRCMaxAge ($wgRCMaxAge) won't be shown", ),
+ "NOTE: If {$p}show=patrolled or {$p}show=!patrolled is set, revisions older than \$wgRCMaxAge ($wgRCMaxAge) won't be shown", ),
'tag' => 'Only list revisions tagged with this tag',
'toponly' => 'Only list changes which are the latest revision',
);
$result->setIndexedTagName( $acceptLang, 'lang' );
$vals['acceptlang'] = $acceptLang;
}
+
return $vals;
}
}
}
}
+
return $retval;
}
'userrights' => array( 'ApiQueryUsers', 'getUserrightsToken' ),
);
wfRunHooks( 'APIQueryUsersTokens', array( &$this->tokenFunctions ) );
+
return $this->tokenFunctions;
}
*/
public static function getUserrightsToken( $user ) {
global $wgUser;
+
// Since the permissions check for userrights is non-trivial,
// don't bother with it here
return $wgUser->getEditToken( $user->getName() );
if ( $n === false || $n === '' ) {
$vals = array( 'name' => $u, 'invalid' => '' );
$fit = $result->addValue( array( 'query', $this->getModuleName() ),
- null, $vals );
+ null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'users',
- implode( '|', array_diff( $users, $done ) ) );
+ implode( '|', array_diff( $users, $done ) ) );
$goodNames = array();
break;
}
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ),
- null, $data[$u] );
+ null, $data[$u] );
if ( !$fit ) {
$this->setContinueEnumParameter( 'users',
- implode( '|', array_diff( $users, $done ) ) );
+ implode( '|', array_diff( $users, $done ) ) );
break;
}
$done[] = $u;
}
private $fld_ids = false, $fld_title = false, $fld_patrol = false, $fld_flags = false,
- $fld_timestamp = false, $fld_user = false, $fld_comment = false, $fld_parsedcomment = false, $fld_sizes = false,
- $fld_notificationtimestamp = false, $fld_userid = false, $fld_loginfo = false;
+ $fld_timestamp = false, $fld_user = false, $fld_comment = false, $fld_parsedcomment = false, $fld_sizes = false,
+ $fld_notificationtimestamp = false, $fld_userid = false, $fld_loginfo = false;
/**
* @param $resultPageSet ApiPageSet
'wl_user' => $userId,
'wl_namespace=rc_namespace',
'wl_title=rc_title'
- ) ) ) );
+ )
+ ) ) );
$this->addWhere( array(
'rc_deleted' => 0,
/* Check for conflicting parameters. */
if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
- || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
- || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
- || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
+ || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
+ || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
+ || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
) {
$this->dieUsageMsg( 'show' );
}
$res = $this->select( __METHOD__ );
foreach ( $res as $row ) {
- if ( ++ $count > $params['limit'] ) {
+ if ( ++$count > $params['limit'] ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
break;
$fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ), null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'start',
- wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
+ wfTimestamp( TS_ISO_8601, $row->rc_timestamp ) );
break;
}
} else {
foreach ( $type as $t ) {
$retval[] = $this->parseRCType( $t );
}
+
return $retval;
}
switch ( $type ) {
public function getParamDescription() {
$p = $this->getModulePrefix();
+
return array(
'allrev' => 'Include multiple revisions of the same page within given timeframe',
'start' => 'The timestamp to start enumerating from',
public function getResultProperties() {
global $wgLogTypes;
+
return array(
'' => array(
'type' => array(
$this->addOption( 'ORDER BY', array(
'wl_namespace' . $sort,
'wl_title' . $sort
- ));
+ ) );
}
$this->addOption( 'LIMIT', $params['limit'] + 1 );
$res = $this->select( __METHOD__ );
if ( is_null( $resultPageSet ) ) {
$vals = array();
ApiQueryBase::addTitleInfo( $vals, $t );
- if ( isset( $prop['changed'] ) && !is_null( $row->wl_notificationtimestamp ) )
- {
+ if ( isset( $prop['changed'] ) && !is_null( $row->wl_notificationtimestamp ) ) {
$vals['changed'] = wfTimestamp( TS_ISO_8601, $row->wl_notificationtimestamp );
}
$fit = $this->getResult()->addValue( $this->getModuleName(), null, $vals );