r67669 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67668‎ | r67669 | r67670 >
Date:20:50, 8 June 2010
Author:reedy
Status:ok
Tags:
Comment:
Fixup mixture of copy pasta fail, and some oversights from r66891 due to comments by Roan
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryIWBacklinks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryIWBacklinks.php
@@ -40,14 +40,10 @@
4141 }
4242
4343 public function execute() {
44 - $params = $this->extractRequestParams( false );
45 -
46 - $userMax = ( $this->redirect ? ApiBase::LIMIT_BIG1 / 2 : ApiBase::LIMIT_BIG1 );
47 - $botMax = ( $this->redirect ? ApiBase::LIMIT_BIG2 / 2 : ApiBase::LIMIT_BIG2 );
48 -
49 - if ( $params['limit'] == 'max' ) {
50 - $params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
51 - $this->getResult()->addValue( 'limits', $this->getModuleName(), $params['limit'] );
 44+ $params = $this->extractRequestParams();
 45+
 46+ if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) {
 47+ $this->dieUsageMsg( array( 'missingparam', 'prefix' ) );
5248 }
5349
5450 if ( !is_null( $params['continue'] ) ) {
@@ -75,22 +71,19 @@
7672 $this->addFields( array( 'page_id', 'page_title', 'page_namespace', 'page_is_redirect',
7773 'iwl_from', 'iwl_prefix', 'iwl_title' ) );
7874
79 - if ( $params['prefix'] !== '' ) {
 75+ if ( isset( $params['prefix'] ) ) {
8076 $this->addWhereFld( 'iwl_prefix', $params['prefix'] );
8177 }
8278
83 - if ( $params['title'] !== '' ) {
 79+ if ( isset( $params['title'] ) ) {
8480 $this->addWhereFld( 'iwl_title', $params['title'] );
8581 }
8682
87 - $this->addWhereFld( 'page_namespace', $params['namespace'] );
88 -
8983 $this->addOption( 'LIMIT', $params['limit'] + 1 );
9084 $this->addOption( 'ORDER BY', 'iwl_from' );
91 - $this->addOption( 'STRAIGHT_JOIN' );
9285
9386 $db = $this->getDB();
94 - $res = $this->select( __METHOD__ . '::firstQuery' );
 87+ $res = $this->select( __METHOD__ );
9588
9689 $count = 0;
9790 $result = $this->getResult();
@@ -131,10 +124,6 @@
132125 'prefix' => null,
133126 'title' => null,
134127 'continue' => null,
135 - 'namespace' => array(
136 - ApiBase::PARAM_ISMULTI => true,
137 - ApiBase::PARAM_TYPE => 'namespace'
138 - ),
139128 'limit' => array(
140129 ApiBase::PARAM_DFLT => 10,
141130 ApiBase::PARAM_TYPE => 'limit',
@@ -148,9 +137,8 @@
149138 public function getParamDescription() {
150139 return array(
151140 'prefix' => 'Prefix for the interwiki',
152 - 'title' => 'Interwiki link to search for',
 141+ 'title' => "Interwiki link to search for. Must be used with {$this->getModulePrefix()}prefix",
153142 'continue' => 'When more results are available, use this to continue',
154 - 'namespace' => 'The namespace to enumerate',
155143 'limit' => 'How many total pages to return',
156144 );
157145 }
@@ -165,17 +153,16 @@
166154
167155 public function getPossibleErrors() {
168156 return array_merge( parent::getPossibleErrors(), array(
169 - array( 'invalidtitle', 'title' ),
170 - array( 'missingparam', 'title' ),
 157+ array( 'missingparam', 'prefix' ),
171158 array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
172159 ) );
173160 }
174161
175162 protected function getExamples() {
176163 return array(
177 - 'api.php?action=query&list=iwbacklinks&iwbltitle=Test&iwblprefix=wikibooks',
178 - 'api.php?action=query&generator=iwbacklinks&giwbltitle=Test&iwblprefix=wikibooks&prop=info'
179 - );
 164+ 'api.php?action=query&list=iwbacklinks&iwbltitle=Test&iwblprefix=wikibooks',
 165+ 'api.php?action=query&generator=iwbacklinks&giwbltitle=Test&iwblprefix=wikibooks&prop=info'
 166+ );
180167 }
181168
182169 public function getVersion() {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r66891* (bug 23524) Api Modules as followup to bug 14473 (Add iwlinks table to trac...reedy19:50, 25 May 2010

Status & tagging log