)
);
- public function __construct( $query, $moduleName ) {
+ public function __construct( ApiQuery $query, $moduleName ) {
$settings = $this->backlinksSettings[$moduleName];
$prefix = $settings['prefix'];
$code = $settings['code'];
}
/**
- * @param $resultPageSet ApiPageSet
+ * @param ApiPageSet $resultPageSet
* @return void
*/
private function prepareFirstQuery( $resultPageSet = null ) {
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 );
}
}
/**
- * @param $resultPageSet ApiPageSet
+ * @param ApiPageSet $resultPageSet
* @return void
*/
private function prepareSecondQuery( $resultPageSet = null ) {
$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' ) {
}
/**
- * @param $resultPageSet ApiPageSet
+ * @param ApiPageSet $resultPageSet
* @return void
*/
private function run( $resultPageSet = null ) {
if ( $this->params['limit'] == 'max' ) {
$this->params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
$result->setParsedLimit( $this->getModuleName(), $this->params['limit'] );
+ } else {
+ $this->params['limit'] = intval( $this->params['limit'] );
+ $this->validateLimit( 'limit', $this->params['limit'], 1, $userMax, $botMax );
}
$this->processContinue();
$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...
+ 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 );
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'
+ );
}
}
return;
}
$this->redirID = $redirID;
-
}
protected function getContinueStr( $lastPageID ) {
return $retval;
}
$retval['redirect'] = false;
+
return $retval;
}
);
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( $retval, array(
'filterredir' => 'How to filter for redirects',
'limit' => 'How many total pages to return'
public function getDescription() {
switch ( $this->getModuleName() ) {
case 'backlinks':
- return 'Find all pages that link to the given page';
+ return 'Find all pages that link to the given page.';
case 'embeddedin':
- return 'Find all pages that embed (transclude) the given title';
+ return 'Find all pages that embed (transclude) the given title.';
case 'imageusage':
return 'Find all pages that use the given image title.';
default:
- ApiBase::dieDebug( __METHOD__, 'Unknown module name' );
+ ApiBase::dieDebug( __METHOD__, 'Unknown module name.' );
}
}
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"
+ ),
)
);
}