Index: trunk/phase3/includes/api/ApiQuery.php |
— | — | @@ -243,7 +243,21 @@ |
244 | 244 | $result->setIndexedTagName($normValues, 'n'); |
245 | 245 | $result->addValue('query', 'normalized', $normValues); |
246 | 246 | } |
| 247 | + |
| 248 | + // Interwiki titles |
| 249 | + $intrwValues = array (); |
| 250 | + foreach ($pageSet->getInterwikiTitles() as $rawTitleStr => $interwikiStr) { |
| 251 | + $intrwValues[] = array ( |
| 252 | + 'title' => $rawTitleStr, |
| 253 | + 'iw' => $interwikiStr |
| 254 | + ); |
| 255 | + } |
247 | 256 | |
| 257 | + if (!empty ($intrwValues)) { |
| 258 | + $result->setIndexedTagName($intrwValues, 'i'); |
| 259 | + $result->addValue('query', 'interwiki', $intrwValues); |
| 260 | + } |
| 261 | + |
248 | 262 | // Show redirect information |
249 | 263 | $redirValues = array (); |
250 | 264 | foreach ($pageSet->getRedirectTitles() as $titleStrFrom => $titleStrTo) { |
Index: trunk/phase3/includes/api/ApiPageSet.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | class ApiPageSet extends ApiQueryBase { |
45 | 45 | |
46 | 46 | private $mAllPages; // [ns][dbkey] => page_id or 0 when missing |
47 | | - private $mTitles, $mGoodTitles, $mMissingTitles, $mMissingPageIDs, $mRedirectTitles, $mNormalizedTitles; |
| 47 | + private $mTitles, $mGoodTitles, $mMissingTitles, $mMissingPageIDs, $mRedirectTitles, $mNormalizedTitles, $mInterwikiTitles; |
48 | 48 | private $mResolveRedirects, $mPendingRedirectIDs; |
49 | 49 | private $mGoodRevIDs, $mMissingRevIDs; |
50 | 50 | |
— | — | @@ -59,6 +59,7 @@ |
60 | 60 | $this->mMissingPageIDs = array (); |
61 | 61 | $this->mRedirectTitles = array (); |
62 | 62 | $this->mNormalizedTitles = array (); |
| 63 | + $this->mInterwikiTitles = array (); |
63 | 64 | $this->mGoodRevIDs = array(); |
64 | 65 | $this->mMissingRevIDs = array(); |
65 | 66 | |
— | — | @@ -165,6 +166,15 @@ |
166 | 167 | } |
167 | 168 | |
168 | 169 | /** |
| 170 | + * Get a list of interwiki titles - maps the title given |
| 171 | + * with to the interwiki prefix. |
| 172 | + * @return array raw_prefixed_title (string) => interwiki_prefix (string) |
| 173 | + */ |
| 174 | + public function getInterwikiTitles() { |
| 175 | + return $this->mInterwikiTitles; |
| 176 | + } |
| 177 | + |
| 178 | + /** |
169 | 179 | * Get the list of revision IDs (requested with revids= parameter) |
170 | 180 | * @return array revID (int) => pageID (int) |
171 | 181 | */ |
— | — | @@ -546,6 +556,7 @@ |
547 | 557 | |
548 | 558 | /** |
549 | 559 | * Given an array of title strings, convert them into Title objects. |
| 560 | + * Alternativelly, an array of Title objects may be given. |
550 | 561 | * This method validates access rights for the title, |
551 | 562 | * and appends normalization values to the output. |
552 | 563 | * |
— | — | @@ -558,17 +569,24 @@ |
559 | 570 | foreach ($titles as $title) { |
560 | 571 | |
561 | 572 | $titleObj = is_string($title) ? Title :: newFromText($title) : $title; |
562 | | - |
563 | | - // Validation |
564 | 573 | if (!$titleObj) |
565 | 574 | $this->dieUsage("bad title $titleString", 'invalidtitle'); |
566 | | - if ($titleObj->getNamespace() < 0) |
567 | | - $this->dieUsage("No support for special page $titleString has been implemented", 'unsupportednamespace'); |
568 | | - if (!$titleObj->userCanRead()) |
569 | | - $this->dieUsage("No read permission for $titleString", 'titleaccessdenied'); |
570 | 575 | |
571 | | - $linkBatch->addObj($titleObj); |
| 576 | + $iw = $titleObj->getInterwiki(); |
| 577 | + if (!empty($iw)) { |
| 578 | + // This title is an interwiki link. |
| 579 | + $this->mInterwikiTitles[$titleObj->getPrefixedText()] = $iw; |
| 580 | + } else { |
572 | 581 | |
| 582 | + // Validation |
| 583 | + if ($titleObj->getNamespace() < 0) |
| 584 | + $this->dieUsage("No support for special page $titleString has been implemented", 'unsupportednamespace'); |
| 585 | + if (!$titleObj->userCanRead()) |
| 586 | + $this->dieUsage("No read permission for $titleString", 'titleaccessdenied'); |
| 587 | + |
| 588 | + $linkBatch->addObj($titleObj); |
| 589 | + } |
| 590 | + |
573 | 591 | // Make sure we remember the original title that was given to us |
574 | 592 | // This way the caller can correlate new titles with the originally requested, |
575 | 593 | // i.e. namespace is localized or capitalization is different |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -198,6 +198,8 @@ |
199 | 199 | not exist |
200 | 200 | * (bug 9121) Introduced indexpageids query parameter to list the page_id |
201 | 201 | values of all returned page items |
| 202 | +* (bug 10147) Now interwiki titles are not processed but added to a separate |
| 203 | + "interwiki" section of the output. |
202 | 204 | |
203 | 205 | == Maintenance script changes since 1.10 == |
204 | 206 | |