r79669 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79668‎ | r79669 | r79670 >
Date:21:28, 5 January 2011
Author:reedy
Status:ok
Tags:
Comment:
* (bug 26483) add a iwtitles param to prop=iwlinks
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryIWLinks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryIWLinks.php
@@ -47,6 +47,11 @@
4848 }
4949
5050 $params = $this->extractRequestParams();
 51+
 52+ if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) {
 53+ $this->dieUsageMsg( array( 'missingparam', 'prefix' ) );
 54+ }
 55+
5156 $this->addFields( array(
5257 'iwl_from',
5358 'iwl_prefix',
@@ -74,12 +79,23 @@
7580 );
7681 }
7782
78 - // Don't order by iwl_from if it's constant in the WHERE clause
79 - if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) {
80 - $this->addOption( 'ORDER BY', 'iwl_prefix' );
 83+ if ( isset( $params['prefix'] ) ) {
 84+ $this->addWhereFld( 'iwl_prefix', $params['prefix'] );
 85+ if ( isset( $params['title'] ) ) {
 86+ $this->addWhereFld( 'iwl_title', $params['title'] );
 87+ $this->addOption( 'ORDER BY', 'iwl_from' );
 88+ } else {
 89+ $this->addOption( 'ORDER BY', 'iwl_title, iwl_from' );
 90+ }
8191 } else {
82 - $this->addOption( 'ORDER BY', 'iwl_from, iwl_prefix' );
 92+ // Don't order by iwl_from if it's constant in the WHERE clause
 93+ if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) {
 94+ $this->addOption( 'ORDER BY', 'iwl_prefix' );
 95+ } else {
 96+ $this->addOption( 'ORDER BY', 'iwl_from, iwl_prefix' );
 97+ }
8398 }
 99+
84100 $this->addOption( 'LIMIT', $params['limit'] + 1 );
85101 $res = $this->select( __METHOD__ );
86102
@@ -124,6 +140,8 @@
125141 ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
126142 ),
127143 'continue' => null,
 144+ 'prefix' => null,
 145+ 'title' => null,
128146 );
129147 }
130148
@@ -132,6 +150,8 @@
133151 'url' => 'Whether to get the full URL',
134152 'limit' => 'How many interwiki links to return',
135153 'continue' => 'When more results are available, use this to continue',
 154+ 'prefix' => 'Prefix for the interwiki',
 155+ 'title' => "Interwiki link to search for. Must be used with {$this->getModulePrefix()}prefix",
136156 );
137157 }
138158
@@ -141,6 +161,7 @@
142162
143163 public function getPossibleErrors() {
144164 return array_merge( parent::getPossibleErrors(), array(
 165+ array( 'missingparam', 'prefix' ),
145166 array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
146167 ) );
147168 }
Index: trunk/phase3/RELEASE-NOTES
@@ -78,6 +78,7 @@
7979 * (bug 26482) add a imimages param to prop=images
8080 * (bug 26498) allow LinksUpdate with API
8181 * (bug 26485) add a elextlinks param to prop=extlinks
 82+* (bug 26483) add a iwtitles param to prop=iwlinks
8283
8384 === Languages updated in 1.18 ===
8485

Status & tagging log