r79672 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79671‎ | r79672 | r79673 >
Date:21:51, 5 January 2011
Author:reedy
Status:ok
Tags:
Comment:
* (bug 26484) add a lltitles param to prop=langlinks
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLangLinks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryLangLinks.php
@@ -46,6 +46,11 @@
4747 }
4848
4949 $params = $this->extractRequestParams();
 50+
 51+ if ( isset( $params['title'] ) && !isset( $params['lang'] ) ) {
 52+ $this->dieUsageMsg( array( 'missingparam', 'lang' ) );
 53+ }
 54+
5055 $this->addFields( array(
5156 'll_from',
5257 'll_lang',
@@ -69,12 +74,23 @@
7075 );
7176 }
7277
73 - // Don't order by ll_from if it's constant in the WHERE clause
74 - if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) {
75 - $this->addOption( 'ORDER BY', 'll_lang' );
 78+ if ( isset( $params['lang'] ) ) {
 79+ $this->addWhereFld( 'll_lang', $params['lang'] );
 80+ if ( isset( $params['title'] ) ) {
 81+ $this->addWhereFld( 'll_title', $params['title'] );
 82+ $this->addOption( 'ORDER BY', 'll_from' );
 83+ } else {
 84+ $this->addOption( 'ORDER BY', 'll_title, ll_from' );
 85+ }
7686 } else {
77 - $this->addOption( 'ORDER BY', 'll_from, ll_lang' );
 87+ // Don't order by ll_from if it's constant in the WHERE clause
 88+ if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) {
 89+ $this->addOption( 'ORDER BY', 'll_lang' );
 90+ } else {
 91+ $this->addOption( 'ORDER BY', 'll_from, ll_lang' );
 92+ }
7893 }
 94+
7995 $this->addOption( 'LIMIT', $params['limit'] + 1 );
8096 $res = $this->select( __METHOD__ );
8197
@@ -117,6 +133,8 @@
118134 ),
119135 'continue' => null,
120136 'url' => false,
 137+ 'lang' => null,
 138+ 'title' => null,
121139 );
122140 }
123141
@@ -125,6 +143,8 @@
126144 'limit' => 'How many langlinks to return',
127145 'continue' => 'When more results are available, use this to continue',
128146 'url' => 'Whether to get the full URL',
 147+ 'lang' => 'Language code',
 148+ 'title' => "Link to search for. Must be used with {$this->getModulePrefix()}lang",
129149 );
130150 }
131151
@@ -134,6 +154,7 @@
135155
136156 public function getPossibleErrors() {
137157 return array_merge( parent::getPossibleErrors(), array(
 158+ array( 'missingparam', 'lang' ),
138159 array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
139160 ) );
140161 }
Index: trunk/phase3/RELEASE-NOTES
@@ -79,6 +79,7 @@
8080 * (bug 26498) allow LinksUpdate with API
8181 * (bug 26485) add a elextlinks param to prop=extlinks
8282 * (bug 26483) add a iwtitles param to prop=iwlinks
 83+* (bug 26484) add a lltitles param to prop=langlinks
8384
8485 === Languages updated in 1.18 ===
8586

Status & tagging log