Index: trunk/phase3/includes/api/ApiQueryBacklinks.php |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | */ |
40 | 40 | class ApiQueryBacklinks extends ApiQueryGeneratorBase { |
41 | 41 | |
42 | | - private $rootTitle, $contRedirs, $contLevel, $contTitle, $contID; |
| 42 | + private $params, $rootTitle, $contRedirs, $contLevel, $contTitle, $contID; |
43 | 43 | |
44 | 44 | // output element name, database column field prefix, database table |
45 | 45 | private $backlinksSettings = array ( |
— | — | @@ -98,13 +98,13 @@ |
99 | 99 | } |
100 | 100 | |
101 | 101 | private function run($resultPageSet = null) { |
102 | | - $continue = $namespace = $redirect = $limit = null; |
103 | | - extract($this->extractRequestParams()); |
104 | | - |
| 102 | + $this->params = $this->extractRequestParams(); |
| 103 | + |
| 104 | + $redirect = $this->params['redirect']; |
105 | 105 | if ($redirect) |
106 | 106 | ApiBase :: dieDebug(__METHOD__, 'Redirect has not been implemented', 'notimplemented'); |
107 | 107 | |
108 | | - $this->processContinue($continue, $redirect); |
| 108 | + $this->processContinue(); |
109 | 109 | |
110 | 110 | $this->addFields($this->bl_fields); |
111 | 111 | if (is_null($resultPageSet)) |
— | — | @@ -122,7 +122,9 @@ |
123 | 123 | if ($this->hasNS) |
124 | 124 | $this->addWhereFld($this->bl_ns, $this->rootTitle->getNamespace()); |
125 | 125 | $this->addWhereFld($this->bl_title, $this->rootTitle->getDBkey()); |
126 | | - $this->addWhereFld('page_namespace', $namespace); |
| 126 | + $this->addWhereFld('page_namespace', $this->params['namespace']); |
| 127 | + |
| 128 | + $limit = $this->params['limit']; |
127 | 129 | $this->addOption('LIMIT', $limit +1); |
128 | 130 | $this->addOption('ORDER BY', $this->bl_sort); |
129 | 131 | |
— | — | @@ -130,7 +132,7 @@ |
131 | 133 | $this->addWhereFld('page_is_redirect', 0); |
132 | 134 | |
133 | 135 | $db = $this->getDB(); |
134 | | - if (!is_null($continue)) { |
| 136 | + if (!is_null($this->params['continue'])) { |
135 | 137 | $plfrm = intval($this->contID); |
136 | 138 | if ($this->contLevel == 0) { |
137 | 139 | // For the first level, there is only one target title, so no need for complex filtering |
— | — | @@ -194,20 +196,25 @@ |
195 | 197 | return $vals; |
196 | 198 | } |
197 | 199 | |
198 | | - protected function processContinue($continue, $redirect) { |
| 200 | + protected function processContinue() { |
199 | 201 | $pageSet = $this->getPageSet(); |
200 | 202 | $count = $pageSet->getTitleCount(); |
201 | | - if (!is_null($continue)) { |
202 | | - if ($count !== 0) |
203 | | - $this->dieUsage("When continuing the {$this->getModuleName()} query, no other titles may be provided", 'titles_on_continue'); |
204 | | - $this->parseContinueParam($continue, $redirect); |
| 203 | + |
| 204 | + if (!is_null($this->params['continue'])) { |
| 205 | + $this->parseContinueParam(); |
205 | 206 | |
206 | 207 | // Skip all completed links |
207 | 208 | |
208 | 209 | } else { |
209 | | - if ($count !== 1) |
210 | | - $this->dieUsage("The {$this->getModuleName()} query requires one title to start", 'bad_title_count'); |
211 | | - $this->rootTitle = current($pageSet->getTitles()); // only one title there |
| 210 | + $title = $this->params['title']; |
| 211 | + if (!is_null($title)) { |
| 212 | + $this->rootTitle = Title :: newFromText($title); |
| 213 | + } else { // This case is obsolete. Will support this for a while |
| 214 | + if ($count !== 1) |
| 215 | + $this->dieUsage("The {$this->getModuleName()} query requires one title to start", 'bad_title_count'); |
| 216 | + $this->rootTitle = current($pageSet->getTitles()); // only one title there |
| 217 | + $this->setWarning('Using titles parameter is obsolete for this list. Use ' . $this->encodeParamName('title') . ' instead.'); |
| 218 | + } |
212 | 219 | } |
213 | 220 | |
214 | 221 | // only image titles are allowed for the root |
— | — | @@ -215,9 +222,9 @@ |
216 | 223 | $this->dieUsage("The title for {$this->getModuleName()} query must be an image", 'bad_image_title'); |
217 | 224 | } |
218 | 225 | |
219 | | - protected function parseContinueParam($continue, $redirect) { |
220 | | - $continueList = explode('|', $continue); |
221 | | - if ($redirect) { |
| 226 | + protected function parseContinueParam() { |
| 227 | + $continueList = explode('|', $this->params['continue']); |
| 228 | + if ($this->params['redirect']) { |
222 | 229 | // |
223 | 230 | // expected redirect-mode parameter: |
224 | 231 | // ns|db_key|step|level|ns|db_key|id |
— | — | @@ -312,6 +319,7 @@ |
313 | 320 | protected function getAllowedParams() { |
314 | 321 | |
315 | 322 | return array ( |
| 323 | + 'title' => null, |
316 | 324 | 'continue' => null, |
317 | 325 | 'namespace' => array ( |
318 | 326 | ApiBase :: PARAM_ISMULTI => true, |
— | — | @@ -330,6 +338,7 @@ |
331 | 339 | |
332 | 340 | protected function getParamDescription() { |
333 | 341 | return array ( |
| 342 | + 'title' => 'Title to search. If null, titles= parameter will be used instead, but will be obsolete soon.', |
334 | 343 | 'continue' => 'When more results are available, use this to continue.', |
335 | 344 | 'namespace' => 'The namespace to enumerate.', |
336 | 345 | 'redirect' => 'If linking page is a redirect, find all pages that link to that redirect (not implemented)', |
— | — | @@ -353,16 +362,16 @@ |
354 | 363 | protected function getExamples() { |
355 | 364 | static $examples = array ( |
356 | 365 | 'backlinks' => array ( |
357 | | - "api.php?action=query&list=backlinks&titles=Main%20Page", |
358 | | - "api.php?action=query&generator=backlinks&titles=Main%20Page&prop=info" |
| 366 | + "api.php?action=query&list=backlinks&bltitle=Main%20Page", |
| 367 | + "api.php?action=query&generator=backlinks&gbltitle=Main%20Page&prop=info" |
359 | 368 | ), |
360 | 369 | 'embeddedin' => array ( |
361 | | - "api.php?action=query&list=embeddedin&titles=Template:Stub", |
362 | | - "api.php?action=query&generator=embeddedin&titles=Template:Stub&prop=info" |
| 370 | + "api.php?action=query&list=embeddedin&eititle=Template:Stub", |
| 371 | + "api.php?action=query&generator=embeddedin&geititle=Template:Stub&prop=info" |
363 | 372 | ), |
364 | 373 | 'imageusage' => array ( |
365 | | - "api.php?action=query&list=imageusage&titles=Image:Albert%20Einstein%20Head.jpg", |
366 | | - "api.php?action=query&generator=imageusage&titles=Image:Albert%20Einstein%20Head.jpg&prop=info" |
| 374 | + "api.php?action=query&list=imageusage&iutitle=Image:Albert%20Einstein%20Head.jpg", |
| 375 | + "api.php?action=query&generator=imageusage&giutitle=Image:Albert%20Einstein%20Head.jpg&prop=info" |
367 | 376 | ) |
368 | 377 | ); |
369 | 378 | |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -125,6 +125,15 @@ |
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
| 129 | + * Set warning section for this module. Users should monitor this section to notice any changes in API. |
| 130 | + */ |
| 131 | + public function setWarning($warning) { |
| 132 | + $msg = array(); |
| 133 | + ApiResult :: setContent($msg, $warning); |
| 134 | + $this->getResult()->addValue('warnings', $this->getModuleName(), $msg); |
| 135 | + } |
| 136 | + |
| 137 | + /** |
129 | 138 | * If the module may only be used with a certain format module, |
130 | 139 | * it should override this method to return an instance of that formatter. |
131 | 140 | * A value of null means the default format will be used. |
Index: trunk/phase3/includes/api/ApiQueryUserContributions.php |
— | — | @@ -135,8 +135,7 @@ |
136 | 136 | $this->addWhereRange('rev_timestamp', |
137 | 137 | $this->params['dir'], $this->params['start'], $this->params['end'] ); |
138 | 138 | |
139 | | - if(count($this->params['namespace']) > 0) |
140 | | - $this->addWhereFld('page_namespace', $this->params['namespace']); |
| 139 | + $this->addWhereFld('page_namespace', $this->params['namespace']); |
141 | 140 | |
142 | 141 | $show = $this->params['show']; |
143 | 142 | if (!is_null($show)) { |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -299,6 +299,8 @@ |
300 | 300 | * (bug 10411) Site language in meta=siteinfo |
301 | 301 | * (bug 10391) action=help doesn't return help if format is fancy markup |
302 | 302 | * (bug 10297) include previous revision ID in prop=revisions |
| 303 | +* backlinks, embeddedin and imageusage lists should use (bl|ei|iu)title parameter |
| 304 | + instead of titles. Titles for these lists is obsolete and might stop working soon. |
303 | 305 | |
304 | 306 | == Maintenance script changes since 1.10 == |
305 | 307 | |