$count = 0;
$result = $this->getResult();
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 ( $params['unique'] ) {
$this->setContinueEnumParameter( 'continue', $row->pl_title );
if ( !$this->hasNamespace ) {
unset( $allowedParams['namespace'] );
}
+
return $allowedParams;
}
if ( !$this->hasNamespace ) {
unset( $paramDescription['namespace'] );
}
+
return $paramDescription;
}
public function getPossibleErrors() {
$m = $this->getModuleName();
$what = $this->descriptionWhat;
+
return array_merge( parent::getPossibleErrors(), array(
array( 'code' => 'params', 'info' => "{$m} cannot return corresponding page ids in unique {$what}s mode" ),
) );
$name = $this->getModuleName();
$what = $this->descriptionWhat;
$targets = $this->descriptionTargets;
+
return array(
"api.php?action=query&list={$name}&{$p}from=B&{$p}prop=ids|title"
- => "List $targets with page ids they are from, including missing ones. Start at B",
+ => "List $targets with page ids they are from, including missing ones. Start at B",
"api.php?action=query&list={$name}&{$p}unique=&{$p}from=B"
- => "List unique $targets",
+ => "List unique $targets",
"api.php?action=query&generator={$name}&g{$p}unique=&g{$p}from=B"
- => "Gets all $targets, marking the missing ones",
+ => "Gets all $targets, marking the missing ones",
"api.php?action=query&generator={$name}&g{$p}from=B"
- => "Gets pages containing the {$what}s",
+ => "Gets pages containing the {$what}s",
);
}
public function getHelpUrls() {
$name = ucfirst( $this->getModuleName() );
+
return "https://www.mediawiki.org/wiki/API:{$name}";
}
}
'messages' => 'Which messages to output. "*" (default) means all messages',
'prop' => 'Which properties to get',
'enableparser' => array( 'Set to enable parser, will preprocess the wikitext of message',
- 'Will substitute magic words, handle templates etc.' ),
+ 'Will substitute magic words, handle templates etc.' ),
'nocontent' => 'If set, do not include the content of the messages in the output.',
'includelocal' => array( "Also include local messages, i.e. messages that don't exist in the software but do exist as a MediaWiki: page.",
- "This lists all MediaWiki: pages, so it will also list those that aren't 'really' messages such as Common.js",
+ "This lists all MediaWiki: pages, so it will also list those that aren't 'really' messages such as Common.js",
),
'title' => 'Page name to use as context when parsing message (for enableparser option)',
'args' => 'Arguments to be substituted into message',
}
$this->addOption( 'DISTINCT' );
-
} elseif ( isset( $params['prlevel'] ) ) {
$this->dieUsage( 'prlevel may not be used without prtype', 'params' );
}
$count = 0;
$result = $this->getResult();
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...
$this->setContinueEnumParameter( 'continue', $row->page_title );
break;
public function getParamDescription() {
$p = $this->getModulePrefix();
+
return array(
'from' => 'The page title to start enumerating from',
'continue' => 'When more results are available, use this to continue',
// no group with the given right(s) exists, no need for a query
if ( !count( $groups ) ) {
$this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), '' );
+
return;
}
// Filter only users that belong to a given group
$this->addTables( 'user_groups', 'ug1' );
$this->addJoinConds( array( 'ug1' => array( 'INNER JOIN', array( 'ug1.ug_user=user_id',
- 'ug1.ug_group' => $params['group'] ) ) ) );
+ 'ug1.ug_group' => $params['group'] ) ) ) );
}
if ( !is_null( $params['excludegroup'] ) && count( $params['excludegroup'] ) ) {
}
$this->addJoinConds( array( 'ug1' => array( 'LEFT OUTER JOIN',
array_merge( array( 'ug1.ug_user=user_id' ), $exclude )
- )
- ) );
+ ) ) );
$this->addWhere( 'ug1.ug_user IS NULL' );
}
// Save the last pass's user data
if ( is_array( $lastUserData ) ) {
$fit = $result->addValue( array( 'query', $this->getModuleName() ),
- null, $lastUserData );
+ null, $lastUserData );
$lastUserData = null;
public function getAllowedParams() {
$userGroups = User::getAllGroups();
+
return array(
'from' => null,
'to' => null,
public function getParamDescription() {
global $wgActiveUserDays;
+
return array(
'from' => 'The user name to start enumerating from',
'to' => 'The user name to stop enumerating at',
' rights - Lists rights that the user has',
' editcount - Adds the edit count of the user',
' registration - Adds the timestamp of when the user registered if available (may be blank)',
- ),
+ ),
'limit' => 'How many total user names to return',
'witheditsonly' => 'Only list users who have made edits',
'activeusers' => "Only list users active in the last {$wgActiveUserDays} days(s)"
$redirNs = $t->getNamespace();
$redirDBkey = $t->getDBkey();
$titleWhere[] = "{$this->bl_title} = " . $db->addQuotes( $redirDBkey ) .
- ( $this->hasNS ? " AND {$this->bl_ns} = {$redirNs}" : '' );
+ ( $this->hasNS ? " AND {$this->bl_ns} = {$redirNs}" : '' );
$allRedirNs[] = $redirNs;
$allRedirDBkey[] = $redirDBkey;
}
$from = $this->redirID;
if ( $this->hasNS ) {
$this->addWhere( "{$this->bl_ns} $op $ns OR " .
- "({$this->bl_ns} = $ns AND " .
- "({$this->bl_title} $op $title OR " .
- "({$this->bl_title} = $title AND " .
- "{$this->bl_from} $op= $from)))" );
+ "({$this->bl_ns} = $ns AND " .
+ "({$this->bl_title} $op $title OR " .
+ "({$this->bl_title} = $title AND " .
+ "{$this->bl_from} $op= $from)))" );
} else {
$this->addWhere( "{$this->bl_title} $op $title OR " .
- "({$this->bl_title} = $title AND " .
- "{$this->bl_from} $op= $from)" );
+ "({$this->bl_title} = $title AND " .
+ "{$this->bl_from} $op= $from)" );
}
}
if ( $this->params['filterredir'] == 'redirects' ) {
$count = 0;
foreach ( $res as $row ) {
- if ( ++ $count > $this->params['limit'] ) {
+ if ( ++$count > $this->params['limit'] ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// Continue string preserved in case the redirect query doesn't pass the limit
$this->continueStr = $this->getContinueStr( $row->page_id );
return;
}
$this->redirID = $redirID;
-
}
protected function getContinueStr( $lastPageID ) {
return $retval;
}
$retval['redirect'] = false;
+
return $retval;
}
'limit' => "How many total pages to return. If {$this->bl_code}redirect is enabled, limit applies to each level separately (which means you may get up to 2 * limit results)."
) );
}
+
return array_merge( $retval, array(
'filterredir' => 'How to filter for redirects',
'limit' => 'How many total pages to return'
protected function addFieldsIf( $value, $condition ) {
if ( $condition ) {
$this->addFields( $value );
+
return true;
}
+
return false;
}
protected function addWhereIf( $value, $condition ) {
if ( $condition ) {
$this->addWhere( $value );
+
return true;
}
+
return false;
}
if ( $rowcount > $wgAPIMaxDBRows ) {
return false;
}
+
return true;
}
protected function addPageSubItems( $pageId, $data ) {
$result = $this->getResult();
$result->setIndexedTagName( $data, $this->getModulePrefix() );
+
return $result->addValue( array( 'query', 'pages', intval( $pageId ) ),
$this->getModuleName(),
$data );
return false;
}
$result->setIndexedTagName_internal( array( 'query', 'pages', $pageId,
- $this->getModuleName() ), $elemname );
+ $this->getModuleName() ), $elemname );
+
return true;
}
if ( is_null( $this->mDb ) ) {
$this->mDb = $this->getQuery()->getDB();
}
+
return $this->mDb;
}
if ( !$t ) {
$this->dieUsageMsg( array( 'invalidtitle', $title ) );
}
+
return $t->getPrefixedDBkey();
}
if ( !$t ) {
$this->dieUsageMsg( array( 'invalidtitle', $key ) );
}
+
return $t->getPrefixedText();
}
* @return string Title part with underscores
*/
public function titlePartToKey( $titlePart ) {
- return substr( $this->titleToKey( $titlePart . 'x' ), 0, - 1 );
+ return substr( $this->titleToKey( $titlePart . 'x' ), 0, -1 );
}
/**
* @return string Key part with underscores
*/
public function keyPartToTitle( $keyPart ) {
- return substr( $this->keyToTitle( $keyPart . 'x' ), 0, - 1 );
+ return substr( $this->keyToTitle( $keyPart . 'x' ), 0, -1 );
}
/**
*/
public function getDirectionDescription( $p = '', $extraDirText = '' ) {
return array(
- "In which direction to enumerate{$extraDirText}",
- " newer - List oldest first. Note: {$p}start has to be before {$p}end.",
- " older - List newest first (default). Note: {$p}start has to be later than {$p}end.",
- );
+ "In which direction to enumerate{$extraDirText}",
+ " newer - List oldest first. Note: {$p}start has to be before {$p}end.",
+ " older - List newest first (default). Note: {$p}start has to be later than {$p}end.",
+ );
}
/**
}
$likeQuery = LinkFilter::keepOneWildcard( $likeQuery );
+
return 'el_index ' . $db->buildLike( $likeQuery );
} elseif ( !is_null( $protocol ) ) {
return 'el_index ' . $db->buildLike( "$protocol", $db->anyString() );
array( 'invalidtitle', 'title' ),
array( 'invalidtitle', 'key' ),
) );
+
return $errors;
}
}
if ( $this->mGeneratorPageSet !== null ) {
return $this->mGeneratorPageSet;
}
+
return parent::getPageSet();
}
$this->addFieldsIf( 'ipb_reason', $fld_reason );
$this->addFieldsIf( array( 'ipb_range_start', 'ipb_range_end' ), $fld_range );
$this->addFieldsIf( array( 'ipb_anon_only', 'ipb_create_account', 'ipb_enable_autoblock',
- 'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk' ),
- $fld_flags );
+ 'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk' ),
+ $fld_flags );
$this->addOption( 'LIMIT', $params['limit'] + 1 );
$this->addTimestampWhereRange( 'ipb_timestamp', $params['dir'], $params['start'], $params['end'] );
/* Check for conflicting parameters. */
if ( ( isset( $show['account'] ) && isset( $show['!account'] ) )
- || ( isset( $show['ip'] ) && isset( $show['!ip'] ) )
- || ( isset( $show['range'] ) && isset( $show['!range'] ) )
- || ( isset( $show['temp'] ) && isset( $show['!temp'] ) )
+ || ( isset( $show['ip'] ) && isset( $show['!ip'] ) )
+ || ( isset( $show['range'] ) && isset( $show['!range'] ) )
+ || ( isset( $show['temp'] ) && isset( $show['!temp'] ) )
) {
$this->dieUsageMsg( 'show' );
}
public function getParamDescription() {
global $wgBlockCIDRLimit;
$p = $this->getModulePrefix();
+
return array(
'start' => 'The timestamp to start enumerating from',
'end' => 'The timestamp to stop enumerating at',
public function getPossibleErrors() {
global $wgBlockCIDRLimit;
+
return array_merge( parent::getPossibleErrors(),
$this->getRequireOnlyOneParameterErrorMessages( array( 'users', 'ip' ) ),
array(
if ( isset( $show['hidden'] ) && isset( $show['!hidden'] ) ) {
$this->dieUsageMsg( 'show' );
}
- if ( isset( $show['hidden'] ) || isset( $show['!hidden'] ) || isset( $prop['hidden'] ) )
- {
+ if ( isset( $show['hidden'] ) || isset( $show['!hidden'] ) || isset( $prop['hidden'] ) ) {
$this->addOption( 'STRAIGHT_JOIN' );
$this->addTables( array( 'page', 'page_props' ) );
$this->addFieldsIf( 'pp_propname', isset( $prop['hidden'] ) );
$this->addOption( 'ORDER BY', 'cl_to' . $sort );
} else {
$this->addOption( 'ORDER BY', array(
- 'cl_from' . $sort,
- 'cl_to' . $sort
- ));
+ 'cl_from' . $sort,
+ 'cl_to' . $sort
+ ) );
}
$res = $this->select( __METHOD__ );
$categories = $alltitles[NS_CATEGORY];
$titles = $this->getPageSet()->getGoodTitles() +
- $this->getPageSet()->getMissingTitles();
+ $this->getPageSet()->getMissingTitles();
$cattitles = array();
foreach ( $categories as $c ) {
/** @var $t Title */
$result = $this->getResult();
$count = 0;
foreach ( $rows 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...
// TODO: Security issue - if the user has no right to view next title, it will still be shown
if ( $params['sort'] == 'timestamp' ) {
$vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp );
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ),
- null, $vals );
+ null, $vals );
if ( !$fit ) {
if ( $params['sort'] == 'timestamp' ) {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
"Note that you can use {$p}type=subcat or {$p}type=file instead of {$p}namespace=14 or 6.",
);
}
+
return $desc;
}