$fld_registration = isset( $prop['registration'] );
$fld_implicitgroups = isset( $prop['implicitgroups'] );
} else {
- $fld_blockinfo = $fld_editcount = $fld_groups = $fld_registration = $fld_rights = $fld_implicitgroups = false;
+ $fld_blockinfo = $fld_editcount = $fld_groups = $fld_registration =
+ $fld_rights = $fld_implicitgroups = false;
}
$limit = $params['limit'];
if ( count( $params['excludegroup'] ) == 1 ) {
$exclude = array( 'ug1.ug_group' => $params['excludegroup'][0] );
} else {
- $exclude = array( $db->makeList( array( 'ug1.ug_group' => $params['excludegroup'] ), LIST_OR ) );
+ $exclude = array( $db->makeList(
+ array( 'ug1.ug_group' => $params['excludegroup'] ),
+ LIST_OR
+ ) );
}
$this->addJoinConds( array( 'ug1' => array( 'LEFT OUTER JOIN',
array_merge( array( 'ug1.ug_user=user_id' ), $exclude )
$lastUser = false;
$result = $this->getResult();
- //
- // This loop keeps track of the last entry.
- // For each new row, if the new row is for different user then the last, the last entry is added to results.
- // Otherwise, the group of the new row is appended to the last entry.
- // The setContinue... is more complex because of this, and takes into account the higher sql limit
- // to make sure all rows that belong to the same user are received.
+ // This loop keeps track of the last entry. For each new row, if the
+ // new row is for different user then the last, the last entry is added
+ // to results. Otherwise, the group of the new row is appended to the
+ // last entry. The setContinue... is more complex because of this, and
+ // takes into account the higher sql limit to make sure all rows that
+ // belong to the same user are received.
foreach ( $res as $row ) {
$count++;
}
if ( $count > $limit ) {
- // We've reached the one extra which shows that there are additional pages to be had. Stop here...
+ // We've reached the one extra which shows that there are
+ // additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'from', $row->user_name );
break;
}
}
if ( $sqlLimit == $count ) {
- // BUG! database contains group name that User::getAllGroups() does not return
- // TODO: should handle this more gracefully
- ApiBase::dieDebug( __METHOD__,
- 'MediaWiki configuration error: the database contains more user groups than known to User::getAllGroups() function' );
+ // @todo BUG! database contains group name that User::getAllGroups() does not return
+ // Should handle this more gracefully
+ ApiBase::dieDebug(
+ __METHOD__,
+ 'MediaWiki configuration error: The database contains more ' .
+ 'user groups than known to User::getAllGroups() function'
+ );
}
$lastUserObj = User::newFromId( $row->user_id );
'dir' => 'Direction to sort in',
'group' => 'Limit users to given group name(s)',
'excludegroup' => 'Exclude users in given group name(s)',
- 'rights' => 'Limit users to given right(s) (does not include rights granted by implicit or auto-promoted groups like *, user, or autoconfirmed)',
+ 'rights' => 'Limit users to given right(s) (does not include rights ' .
+ 'granted by implicit or auto-promoted groups like *, user, or autoconfirmed)',
'prop' => array(
'What pieces of information to include.',
' blockinfo - Adds the information about a current block on the user',
- ' groups - Lists groups that the user is in. This uses more server resources and may return fewer results than the limit',
+ ' groups - Lists groups that the user is in. This uses ' .
+ 'more server resources and may return fewer results than the limit',
' implicitgroups - Lists all the groups the user is automatically in',
' rights - Lists rights that the user has',
' editcount - Adds the edit count of the user',
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
- array( 'code' => 'group-excludegroup', 'info' => 'group and excludegroup cannot be used together' ),
+ array(
+ 'code' => 'group-excludegroup',
+ 'info' => 'group and excludegroup cannot be used together'
+ ),
) );
}
if ( $this->params['filterredir'] == 'redirects' ) {
$this->addWhereFld( 'page_is_redirect', 1 );
} elseif ( $this->params['filterredir'] == 'nonredirects' && !$this->redirect ) {
- // bug 22245 - Check for !redirect, as filtering nonredirects, when getting what links to them is contradictory
+ // bug 22245 - Check for !redirect, as filtering nonredirects, when
+ // getting what links to them is contradictory
$this->addWhereFld( 'page_is_redirect', 0 );
}
foreach ( $res as $row ) {
if ( ++$count > $this->params['limit'] ) {
- // We've reached the one extra which shows that there are additional pages to be had. Stop here...
+ // 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 );
break;
$count = 0;
foreach ( $res as $row ) {
if ( ++$count > $this->params['limit'] ) {
- // We've reached the one extra which shows that there are additional pages to be had. Stop here...
+ // We've reached the one extra which shows that there are
+ // additional pages to be had. Stop here...
// We need to keep the parent page of this redir in
if ( $this->hasNS ) {
$parentID = $this->pageMap[$row->{$this->bl_ns}][$row->{$this->bl_title}];
$parentID = $this->pageMap[$ns][$row->{$this->bl_title}];
// Put all the results in an array first
$this->resultArr[$parentID]['redirlinks'][] = $a;
- $this->getResult()->setIndexedTagName( $this->resultArr[$parentID]['redirlinks'], $this->bl_code );
+ $this->getResult()->setIndexedTagName(
+ $this->resultArr[$parentID]['redirlinks'],
+ $this->bl_code
+ );
}
protected function processContinue() {
// only image titles are allowed for the root in imageinfo mode
if ( !$this->hasNS && $this->rootTitle->getNamespace() !== NS_FILE ) {
- $this->dieUsage( "The title for {$this->getModuleName()} query must be an image", 'bad_image_title' );
+ $this->dieUsage(
+ "The title for {$this->getModuleName()} query must be an image",
+ 'bad_image_title'
+ );
}
}
);
if ( $this->getModuleName() != 'embeddedin' ) {
return array_merge( $retval, array(
- 'redirect' => 'If linking page is a redirect, find all pages that link to that redirect as well. Maximum limit is halved.',
- 'filterredir' => "How to filter for redirects. If set to nonredirects when {$this->bl_code}redirect is enabled, this is only applied to the second level",
- '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)."
+ 'redirect' => 'If linking page is a redirect, find all pages ' .
+ 'that link to that redirect as well. Maximum limit is halved.',
+ 'filterredir' => 'How to filter for redirects. If set to ' .
+ "nonredirects when {$this->bl_code}redirect is enabled, " .
+ 'this is only applied to the second level',
+ '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( parent::getPossibleErrors(),
$this->getTitleOrPageIdErrorMessage(),
array(
- array( 'code' => 'bad_image_title', 'info' => "The title for {$this->getModuleName()} query must be an image" ),
+ array(
+ 'code' => 'bad_image_title',
+ 'info' => "The title for {$this->getModuleName()} query must be an image"
+ ),
)
);
}
if ( $sort ) {
$order = $field . ( $isDirNewer ? '' : ' DESC' );
// Append ORDER BY
- $optionOrderBy = isset( $this->options['ORDER BY'] ) ? (array)$this->options['ORDER BY'] : array();
+ $optionOrderBy = isset( $this->options['ORDER BY'] )
+ ? (array)$this->options['ORDER BY']
+ : array();
$optionOrderBy[] = $order;
$this->addOption( 'ORDER BY', $optionOrderBy );
}
* @param string $method Function the query should be attributed to.
* You should usually use __METHOD__ here
* @param array $extraQuery Query data to add but not store in the object
- * Format is array( 'tables' => ..., 'fields' => ..., 'where' => ..., 'options' => ..., 'join_conds' => ... )
+ * Format is array(
+ * 'tables' => ...,
+ * 'fields' => ...,
+ * 'where' => ...,
+ * 'options' => ...,
+ * 'join_conds' => ...
+ * )
* @return ResultWrapper
*/
protected function select( $method, $extraQuery = array() ) {
- $tables = array_merge( $this->tables, isset( $extraQuery['tables'] ) ? (array)$extraQuery['tables'] : array() );
- $fields = array_merge( $this->fields, isset( $extraQuery['fields'] ) ? (array)$extraQuery['fields'] : array() );
- $where = array_merge( $this->where, isset( $extraQuery['where'] ) ? (array)$extraQuery['where'] : array() );
- $options = array_merge( $this->options, isset( $extraQuery['options'] ) ? (array)$extraQuery['options'] : array() );
- $join_conds = array_merge( $this->join_conds, isset( $extraQuery['join_conds'] ) ? (array)$extraQuery['join_conds'] : array() );
+ $tables = array_merge(
+ $this->tables,
+ isset( $extraQuery['tables'] ) ? (array)$extraQuery['tables'] : array()
+ );
+ $fields = array_merge(
+ $this->fields,
+ isset( $extraQuery['fields'] ) ? (array)$extraQuery['fields'] : array()
+ );
+ $where = array_merge(
+ $this->where,
+ isset( $extraQuery['where'] ) ? (array)$extraQuery['where'] : array()
+ );
+ $options = array_merge(
+ $this->options,
+ isset( $extraQuery['options'] ) ? (array)$extraQuery['options'] : array()
+ );
+ $join_conds = array_merge(
+ $this->join_conds,
+ isset( $extraQuery['join_conds'] ) ? (array)$extraQuery['join_conds'] : array()
+ );
// getDB has its own profileDBIn/Out calls
$db = $this->getDB();
protected function checkRowCount() {
$db = $this->getDB();
$this->profileDBIn();
- $rowcount = $db->estimateRowCount( $this->tables, $this->fields, $this->where, __METHOD__, $this->options );
+ $rowcount = $db->estimateRowCount(
+ $this->tables,
+ $this->fields,
+ $this->where,
+ __METHOD__,
+ $this->options
+ );
$this->profileDBOut();
global $wgAPIMaxDBRows;
$fld_flags );
$this->addOption( 'LIMIT', $params['limit'] + 1 );
- $this->addTimestampWhereRange( 'ipb_timestamp', $params['dir'], $params['start'], $params['end'] );
+ $this->addTimestampWhereRange(
+ 'ipb_timestamp',
+ $params['dir'],
+ $params['start'],
+ $params['end']
+ );
$db = $this->getDB();
# Check range validity, if it's a CIDR
list( $ip, $range ) = IP::parseCIDR( $params['ip'] );
if ( $ip !== false && $range !== false && $range < $cidrLimit ) {
- $this->dieUsage( "$type CIDR ranges broader than /$cidrLimit are not accepted", 'cidrtoobroad' );
+ $this->dieUsage(
+ "$type CIDR ranges broader than /$cidrLimit are not accepted",
+ 'cidrtoobroad'
+ );
}
# Let IP::parseRange handle calculating $upper, instead of duplicating the logic here.
$this->addWhereIf( 'ipb_user != 0', isset( $show['account'] ) );
$this->addWhereIf( 'ipb_user != 0 OR ipb_range_end > ipb_range_start', isset( $show['!ip'] ) );
$this->addWhereIf( 'ipb_user = 0 AND ipb_range_end = ipb_range_start', isset( $show['ip'] ) );
- $this->addWhereIf( 'ipb_expiry = ' . $db->addQuotes( $db->getInfinity() ), isset( $show['!temp'] ) );
- $this->addWhereIf( 'ipb_expiry != ' . $db->addQuotes( $db->getInfinity() ), isset( $show['temp'] ) );
+ $this->addWhereIf( 'ipb_expiry = ' .
+ $db->addQuotes( $db->getInfinity() ), isset( $show['!temp'] ) );
+ $this->addWhereIf( 'ipb_expiry != ' .
+ $db->addQuotes( $db->getInfinity() ), isset( $show['temp'] ) );
$this->addWhereIf( 'ipb_range_end = ipb_range_start', isset( $show['!range'] ) );
$this->addWhereIf( 'ipb_range_end > ipb_range_start', isset( $show['range'] ) );
}
return array(
'prop' => array(
'Which additional properties to get for each category',
- ' sortkey - Adds the sortkey (hexadecimal string) and sortkey prefix (human-readable part) for the category',
+ ' sortkey - Adds the sortkey (hexadecimal string) and sortkey prefix',
+ ' (human-readable part) for the category',
' timestamp - Adds timestamp of when the category was added',
' hidden - Tags categories that are hidden with __HIDDENCAT__',
),
'limit' => 'How many categories to return',
'show' => 'Which kind of categories to show',
'continue' => 'When more results are available, use this to continue',
- 'categories' => 'Only list these categories. Useful for checking whether a certain page is in a certain category',
+ 'categories' => 'Only list these categories. Useful for checking ' .
+ 'whether a certain page is in a certain category',
'dir' => 'The direction in which to list',
);
}
public function getExamples() {
return array(
- 'api.php?action=query&prop=categories&titles=Albert%20Einstein' => 'Get a list of categories [[Albert Einstein]] belongs to',
- 'api.php?action=query&generator=categories&titles=Albert%20Einstein&prop=info' => 'Get information about all categories used in the [[Albert Einstein]]',
+ 'api.php?action=query&prop=categories&titles=Albert%20Einstein'
+ => 'Get a list of categories [[Albert Einstein]] belongs to',
+ 'api.php?action=query&generator=categories&titles=Albert%20Einstein&prop=info'
+ => 'Get information about all categories used in the [[Albert Einstein]]',
);
}
'pp_propname' => 'hiddencat' ) ),
) );
- $this->addFields( array( 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files', 'cat_hidden' => 'pp_propname' ) );
+ $this->addFields( array(
+ 'cat_title',
+ 'cat_pages',
+ 'cat_subcats',
+ 'cat_files',
+ 'cat_hidden' => 'pp_propname'
+ ) );
$this->addWhere( array( 'cat_title' => $cattitles ) );
if ( !is_null( $params['continue'] ) ) {
$count = 0;
foreach ( $rows as $row ) {
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
+ // 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' ) {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
} else {
global $wgMiserMode;
$p = $this->getModulePrefix();
$desc = array(
- 'title' => "Which category to enumerate (required). Must include Category: prefix. Cannot be used together with {$p}pageid",
+ 'title' => "Which category to enumerate (required). Must include ' .
+ 'Category: prefix. Cannot be used together with {$p}pageid",
'pageid' => "Page ID of the category to enumerate. Cannot be used together with {$p}title",
'prop' => array(
'What pieces of information to include',
' ids - Adds the page ID',
' title - Adds the title and namespace ID of the page',
' sortkey - Adds the sortkey used for sorting in the category (hexadecimal string)',
- ' sortkeyprefix - Adds the sortkey prefix used for sorting in the category (human-readable part of the sortkey)',
+ ' sortkeyprefix - Adds the sortkey prefix used for sorting in the ' .
+ 'category (human-readable part of the sortkey)',
' type - Adds the type that the page has been categorised as (page, subcat or file)',
' timestamp - Adds the timestamp of when the page was included',
),
'dir' => 'In which direction to sort',
'start' => "Timestamp to start listing from. Can only be used with {$p}sort=timestamp",
'end' => "Timestamp to end listing at. Can only be used with {$p}sort=timestamp",
- 'startsortkey' => "Sortkey to start listing from. Must be given in binary format. Can only be used with {$p}sort=sortkey",
- 'endsortkey' => "Sortkey to end listing at. Must be given in binary format. Can only be used with {$p}sort=sortkey",
- 'startsortkeyprefix' => "Sortkey prefix to start listing from. Can only be used with {$p}sort=sortkey. Overrides {$p}startsortkey",
- 'endsortkeyprefix' => "Sortkey prefix to end listing BEFORE (not at, if this value occurs it will not be included!). Can only be used with {$p}sort=sortkey. Overrides {$p}endsortkey",
+ 'startsortkey' => "Sortkey to start listing from. Must be given in ' .
+ 'binary format. Can only be used with {$p}sort=sortkey",
+ 'endsortkey' => "Sortkey to end listing at. Must be given in binary ' .
+ 'format. Can only be used with {$p}sort=sortkey",
+ 'startsortkeyprefix' => "Sortkey prefix to start listing from. Can ' .
+ 'only be used with {$p}sort=sortkey. Overrides {$p}startsortkey",
+ 'endsortkeyprefix' => "Sortkey prefix to end listing BEFORE (not at, ' .
+ 'if this value occurs it will not be included!). Can only be used with ' .
+ '{$p}sort=sortkey. Overrides {$p}endsortkey",
'continue' => 'For large categories, give the value returned from previous query',
'limit' => 'The maximum number of pages to return.',
);
public function getExamples() {
return array(
- 'api.php?action=query&list=categorymembers&cmtitle=Category:Physics' => 'Get first 10 pages in [[Category:Physics]]',
- 'api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info' => 'Get page info about first 10 pages in [[Category:Physics]]',
+ 'api.php?action=query&list=categorymembers&cmtitle=Category:Physics'
+ => 'Get first 10 pages in [[Category:Physics]]',
+ 'api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info'
+ => 'Get page info about first 10 pages in [[Category:Physics]]',
);
}
$user = $this->getUser();
// Before doing anything at all, let's check permissions
if ( !$user->isAllowed( 'deletedhistory' ) ) {
- $this->dieUsage( 'You don\'t have permission to view deleted revision information', 'permissiondenied' );
+ $this->dieUsage(
+ 'You don\'t have permission to view deleted revision information',
+ 'permissiondenied'
+ );
}
$db = $this->getDB();
// This also means stricter restrictions
if ( !$user->isAllowed( 'undelete' ) ) {
- $this->dieUsage( 'You don\'t have permission to view deleted revision content', 'permissiondenied' );
+ $this->dieUsage(
+ 'You don\'t have permission to view deleted revision content',
+ 'permissiondenied'
+ );
}
}
// Check limits
$this->addWhereRange( 'ar_title', $dir, $from, $to );
if ( isset( $params['prefix'] ) ) {
- $this->addWhere( 'ar_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
+ $this->addWhere( 'ar_title' .
+ $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
}
}
}
$this->addOption( 'LIMIT', $limit + 1 );
- $this->addOption( 'USE INDEX', array( 'archive' => ( $mode == 'user' ? 'usertext_timestamp' : 'name_title_timestamp' ) ) );
+ $this->addOption(
+ 'USE INDEX',
+ array( 'archive' => ( $mode == 'user' ? 'usertext_timestamp' : 'name_title_timestamp' ) )
+ );
if ( $mode == 'all' ) {
if ( $params['unique'] ) {
$this->addOption( 'GROUP BY', 'ar_title' );
'Operates in three modes:',
' 1) List deleted revisions for the given title(s), sorted by timestamp',
' 2) List deleted contributions for the given user, sorted by timestamp (no titles specified)',
- " 3) List all deleted revisions in the given namespace, sorted by title and timestamp (no titles specified, {$p}user not set)",
+ " 3) List all deleted revisions in the given namespace, sorted by title and timestamp',
+ ' (no titles specified, {$p}user not set)",
'Certain parameters only apply to some modes and are ignored in others.',
'For instance, a parameter marked (1) only applies to mode 1 and is ignored in modes 2 and 3',
);
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
- array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revision information' ),
- array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ),
- array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revision content' ),
+ array(
+ 'code' => 'permissiondenied',
+ 'info' => 'You don\'t have permission to view deleted revision information'
+ ),
+ array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together'
+ ),
+ array(
+ 'code' => 'permissiondenied',
+ 'info' => 'You don\'t have permission to view deleted revision content'
+ ),
array( 'code' => 'badparams', 'info' => "The 'from' parameter cannot be used in modes 1 or 2" ),
array( 'code' => 'badparams', 'info' => "The 'to' parameter cannot be used in modes 1 or 2" ),
- array( 'code' => 'badparams', 'info' => "The 'prefix' parameter cannot be used in modes 1 or 2" ),
+ array(
+ 'code' => 'badparams',
+ 'info' => "The 'prefix' parameter cannot be used in modes 1 or 2"
+ ),
array( 'code' => 'badparams', 'info' => "The 'start' parameter cannot be used in mode 3" ),
array( 'code' => 'badparams', 'info' => "The 'end' parameter cannot be used in mode 3" ),
) );
public function getExamples() {
return array(
- 'api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content'
+ 'api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&' .
+ 'drprop=user|comment|content'
=> 'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1)',
'api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50'
=> 'List the last 50 deleted contributions by Bob (mode 2)',