r44185 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44184‎ | r44185 | r44186 >
Date:19:30, 3 December 2008
Author:demon
Status:reverted (Comments)
Tags:
Comment:
Foreign repos (API or DB) now fetch images and/or description pages if the repo wiki has a different canonical name for the File: namespace. Added 'fileNamespace' configuration item to $wgForeignFileRepos to override the local canonical name.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/filerepo/FileRepo.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignAPIRepo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -15,7 +15,7 @@
1616 var $thumbScriptUrl, $transformVia404;
1717 var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription, $initialCapital;
1818 var $pathDisclosureProtection = 'paranoid';
19 - var $descriptionCacheExpiry, $apiThumbCacheExpiry, $hashLevels;
 19+ var $descriptionCacheExpiry, $apiThumbCacheExpiry, $hashLevels, $fileNamespace;
2020
2121 /**
2222 * Factory functions for creating new files
@@ -30,9 +30,10 @@
3131
3232 // Optional settings
3333 $this->initialCapital = true; // by default
 34+ $this->fileNamespace = MWNamespace::getCanonicalName( NS_FILE ); // fallback to 'File'
3435 foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription',
3536 'thumbScriptUrl', 'initialCapital', 'pathDisclosureProtection',
36 - 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'hashLevels' ) as $var )
 37+ 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'hashLevels', 'fileNamespace' ) as $var )
3738 {
3839 if ( isset( $info[$var] ) ) {
3940 $this->$var = $info[$var];
@@ -262,10 +263,10 @@
263264 if ( is_null( $this->descBaseUrl ) ) {
264265 if ( !is_null( $this->articleUrl ) ) {
265266 $this->descBaseUrl = str_replace( '$1',
266 - wfUrlencode( MWNamespace::getCanonicalName( NS_FILE ) ) . ':', $this->articleUrl );
 267+ wfUrlencode( $this->getFileNamespace() ) . ':', $this->articleUrl );
267268 } elseif ( !is_null( $this->scriptDirUrl ) ) {
268269 $this->descBaseUrl = $this->scriptDirUrl . '/index.php?title=' .
269 - wfUrlencode( MWNamespace::getCanonicalName( NS_FILE ) ) . ':';
 270+ wfUrlencode( $this->getFileNamespace() ) . ':';
270271 } else {
271272 $this->descBaseUrl = false;
272273 }
@@ -300,7 +301,7 @@
301302 function getDescriptionRenderUrl( $name ) {
302303 if ( isset( $this->scriptDirUrl ) ) {
303304 return $this->scriptDirUrl . '/index.php?title=' .
304 - wfUrlencode( MWNamespace::getCanonicalName( NS_FILE ) . ':' . $name ) .
 305+ wfUrlencode( $this->getFileNamespace() . ':' . $name ) .
305306 '&action=render';
306307 } else {
307308 $descBase = $this->getDescBaseUrl();
@@ -534,4 +535,11 @@
535536 function findBySha1( $hash ) {
536537 return array();
537538 }
 539+ /**
 540+ * Returns the file namespace string
 541+ * @return strig
 542+ */
 543+ function getFileNamespace() {
 544+ return $this->fileNamespace;
 545+ }
538546 }
Index: trunk/phase3/includes/filerepo/ForeignAPIRepo.php
@@ -94,7 +94,7 @@
9595
9696 function getImageInfo( $title, $time = false ) {
9797 return $this->queryImage( array(
98 - 'titles' => 'Image:' . $title->getText(),
 98+ 'titles' => $this->getFileNamespace() . ':' . $title->getText(),
9999 'iiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime' ) );
100100 }
101101
Index: trunk/phase3/RELEASE-NOTES
@@ -388,6 +388,10 @@
389389 * (bug 16026) 'Revision-info' and 'revision-info-current' both accept wiki
390390 markup now.
391391 * (bug 16529) Fix for search suggestions with some third-party JS libraries
 392+* Foreign repositories (API or DB) would fail to fetch images and/or description
 393+ pages if the repo wiki had a different canonical name for the File: namespace.
 394+ Added 'fileNamespace' configuration item to $wgForeignFileRepos to override
 395+ the local canonical name 'File' with another string.
392396
393397
394398 === API changes in 1.14 ===

Follow-up revisions

RevisionCommit summaryAuthorDate
r44204Revert r44185, r44186 -- "Foreign repos (API or DB) now fetch images and/or d...brion23:49, 3 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   23:53, 3 December 2008

The canonical-canonical 'Image' namespace name should always be used here for compatibility. Reverted in r44204

Status & tagging log