r22974 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22973‎ | r22974 | r22975 >
Date:03:14, 14 June 2007
Author:yurik
Status:old
Tags:
Comment:
API: fixed bug 10147 Silent normalization of interwiki titles
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiPageSet.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuery.php
@@ -243,7 +243,21 @@
244244 $result->setIndexedTagName($normValues, 'n');
245245 $result->addValue('query', 'normalized', $normValues);
246246 }
 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+ }
247256
 257+ if (!empty ($intrwValues)) {
 258+ $result->setIndexedTagName($intrwValues, 'i');
 259+ $result->addValue('query', 'interwiki', $intrwValues);
 260+ }
 261+
248262 // Show redirect information
249263 $redirValues = array ();
250264 foreach ($pageSet->getRedirectTitles() as $titleStrFrom => $titleStrTo) {
Index: trunk/phase3/includes/api/ApiPageSet.php
@@ -43,7 +43,7 @@
4444 class ApiPageSet extends ApiQueryBase {
4545
4646 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;
4848 private $mResolveRedirects, $mPendingRedirectIDs;
4949 private $mGoodRevIDs, $mMissingRevIDs;
5050
@@ -59,6 +59,7 @@
6060 $this->mMissingPageIDs = array ();
6161 $this->mRedirectTitles = array ();
6262 $this->mNormalizedTitles = array ();
 63+ $this->mInterwikiTitles = array ();
6364 $this->mGoodRevIDs = array();
6465 $this->mMissingRevIDs = array();
6566
@@ -165,6 +166,15 @@
166167 }
167168
168169 /**
 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+ /**
169179 * Get the list of revision IDs (requested with revids= parameter)
170180 * @return array revID (int) => pageID (int)
171181 */
@@ -546,6 +556,7 @@
547557
548558 /**
549559 * Given an array of title strings, convert them into Title objects.
 560+ * Alternativelly, an array of Title objects may be given.
550561 * This method validates access rights for the title,
551562 * and appends normalization values to the output.
552563 *
@@ -558,17 +569,24 @@
559570 foreach ($titles as $title) {
560571
561572 $titleObj = is_string($title) ? Title :: newFromText($title) : $title;
562 -
563 - // Validation
564573 if (!$titleObj)
565574 $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');
570575
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 {
572581
 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+
573591 // Make sure we remember the original title that was given to us
574592 // This way the caller can correlate new titles with the originally requested,
575593 // i.e. namespace is localized or capitalization is different
Index: trunk/phase3/RELEASE-NOTES
@@ -198,6 +198,8 @@
199199 not exist
200200 * (bug 9121) Introduced indexpageids query parameter to list the page_id
201201 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.
202204
203205 == Maintenance script changes since 1.10 ==
204206

Follow-up revisions

RevisionCommit summaryAuthorDate
r23039Merged revisions 22967-23037 via svnmerge from...david20:15, 16 June 2007

Status & tagging log