From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/api/ApiQueryBacklinks.php | 83 ++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 44 deletions(-) (limited to 'includes/api/ApiQueryBacklinks.php') diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 2d1089a7..c141246d 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -75,7 +75,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { ) ); - public function __construct( $query, $moduleName ) { + public function __construct( ApiQuery $query, $moduleName ) { $settings = $this->backlinksSettings[$moduleName]; $prefix = $settings['prefix']; $code = $settings['code']; @@ -116,7 +116,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { } /** - * @param $resultPageSet ApiPageSet + * @param ApiPageSet $resultPageSet * @return void */ private function prepareFirstQuery( $resultPageSet = null ) { @@ -149,7 +149,8 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { 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 ); } @@ -160,7 +161,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { } /** - * @param $resultPageSet ApiPageSet + * @param ApiPageSet $resultPageSet * @return void */ private function prepareSecondQuery( $resultPageSet = null ) { @@ -193,7 +194,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $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; } @@ -209,14 +210,14 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $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' ) { @@ -241,7 +242,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { } /** - * @param $resultPageSet ApiPageSet + * @param ApiPageSet $resultPageSet * @return void */ private function run( $resultPageSet = null ) { @@ -268,8 +269,9 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $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; @@ -294,7 +296,8 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $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}]; @@ -384,7 +387,10 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $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() { @@ -396,7 +402,10 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { // 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' + ); } } @@ -428,7 +437,6 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { return; } $this->redirID = $redirID; - } protected function getContinueStr( $lastPageID ) { @@ -481,6 +489,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { return $retval; } $retval['redirect'] = false; + return $retval; } @@ -494,50 +503,36 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { ); 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 getResultProperties() { - return array( - '' => array( - 'pageid' => 'integer', - 'ns' => 'namespace', - 'title' => 'string', - 'redirect' => 'boolean' - ) - ); - } - 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.' ); } } - public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), - $this->getTitleOrPageIdErrorMessage(), - array( - array( 'code' => 'bad_image_title', 'info' => "The title for {$this->getModuleName()} query must be an image" ), - ) - ); - } - public function getExamples() { static $examples = array( 'backlinks' => array( -- cgit v1.2.3-54-g00ecf