Index: trunk/phase3/includes/api/ApiQueryIWLinks.php |
— | — | @@ -47,6 +47,11 @@ |
48 | 48 | } |
49 | 49 | |
50 | 50 | $params = $this->extractRequestParams(); |
| 51 | + |
| 52 | + if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) { |
| 53 | + $this->dieUsageMsg( array( 'missingparam', 'prefix' ) ); |
| 54 | + } |
| 55 | + |
51 | 56 | $this->addFields( array( |
52 | 57 | 'iwl_from', |
53 | 58 | 'iwl_prefix', |
— | — | @@ -74,12 +79,23 @@ |
75 | 80 | ); |
76 | 81 | } |
77 | 82 | |
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 | + } |
81 | 91 | } 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 | + } |
83 | 98 | } |
| 99 | + |
84 | 100 | $this->addOption( 'LIMIT', $params['limit'] + 1 ); |
85 | 101 | $res = $this->select( __METHOD__ ); |
86 | 102 | |
— | — | @@ -124,6 +140,8 @@ |
125 | 141 | ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
126 | 142 | ), |
127 | 143 | 'continue' => null, |
| 144 | + 'prefix' => null, |
| 145 | + 'title' => null, |
128 | 146 | ); |
129 | 147 | } |
130 | 148 | |
— | — | @@ -132,6 +150,8 @@ |
133 | 151 | 'url' => 'Whether to get the full URL', |
134 | 152 | 'limit' => 'How many interwiki links to return', |
135 | 153 | '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", |
136 | 156 | ); |
137 | 157 | } |
138 | 158 | |
— | — | @@ -141,6 +161,7 @@ |
142 | 162 | |
143 | 163 | public function getPossibleErrors() { |
144 | 164 | return array_merge( parent::getPossibleErrors(), array( |
| 165 | + array( 'missingparam', 'prefix' ), |
145 | 166 | array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), |
146 | 167 | ) ); |
147 | 168 | } |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -78,6 +78,7 @@ |
79 | 79 | * (bug 26482) add a imimages param to prop=images |
80 | 80 | * (bug 26498) allow LinksUpdate with API |
81 | 81 | * (bug 26485) add a elextlinks param to prop=extlinks |
| 82 | +* (bug 26483) add a iwtitles param to prop=iwlinks |
82 | 83 | |
83 | 84 | === Languages updated in 1.18 === |
84 | 85 | |