From 9cdbc375ba467da6ad0ba5a9ecd7ad3116fe841f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 3 Dec 2008 23:49:04 +0000 Subject: [PATCH] Revert r44185, r44186 -- "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." The canonical-canonical 'Image' namespace name should always be used here for compatibility; an extra configuration option is unnecessary and adds confusion. --- RELEASE-NOTES | 4 ---- includes/filerepo/FileRepo.php | 18 +++++------------- includes/filerepo/ForeignAPIRepo.php | 2 +- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a2c204cef5..0e1acd15c5 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -386,10 +386,6 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 16026) 'Revision-info' and 'revision-info-current' both accept wiki markup now. * (bug 16529) Fix for search suggestions with some third-party JS libraries -* Foreign repositories (API or DB) would fail to fetch images and/or description - pages if the repo wiki had a different canonical name for the File: namespace. - Added 'fileNamespace' configuration item to $wgForeignFileRepos to override - the local canonical name 'File' with another string. * (bug 13342) importScript() generates more consistent URI encoding diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 1649f1fee6..6208976c93 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -15,7 +15,7 @@ abstract class FileRepo { var $thumbScriptUrl, $transformVia404; var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription, $initialCapital; var $pathDisclosureProtection = 'paranoid'; - var $descriptionCacheExpiry, $apiThumbCacheExpiry, $hashLevels, $fileNamespace; + var $descriptionCacheExpiry, $apiThumbCacheExpiry, $hashLevels; /** * Factory functions for creating new files @@ -30,10 +30,9 @@ abstract class FileRepo { // Optional settings $this->initialCapital = true; // by default - $this->fileNamespace = MWNamespace::getCanonicalName( NS_FILE ); // fallback to 'File' foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription', 'thumbScriptUrl', 'initialCapital', 'pathDisclosureProtection', - 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'hashLevels', 'fileNamespace' ) as $var ) + 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'hashLevels' ) as $var ) { if ( isset( $info[$var] ) ) { $this->$var = $info[$var]; @@ -263,10 +262,10 @@ abstract class FileRepo { if ( is_null( $this->descBaseUrl ) ) { if ( !is_null( $this->articleUrl ) ) { $this->descBaseUrl = str_replace( '$1', - wfUrlencode( $this->getFileNamespace() ) . ':', $this->articleUrl ); + wfUrlencode( MWNamespace::getCanonicalName( NS_FILE ) ) . ':', $this->articleUrl ); } elseif ( !is_null( $this->scriptDirUrl ) ) { $this->descBaseUrl = $this->scriptDirUrl . '/index.php?title=' . - wfUrlencode( $this->getFileNamespace() ) . ':'; + wfUrlencode( MWNamespace::getCanonicalName( NS_FILE ) ) . ':'; } else { $this->descBaseUrl = false; } @@ -301,7 +300,7 @@ abstract class FileRepo { function getDescriptionRenderUrl( $name ) { if ( isset( $this->scriptDirUrl ) ) { return $this->scriptDirUrl . '/index.php?title=' . - wfUrlencode( $this->getFileNamespace() . ':' . $name ) . + wfUrlencode( MWNamespace::getCanonicalName( NS_FILE ) . ':' . $name ) . '&action=render'; } else { $descBase = $this->getDescBaseUrl(); @@ -535,11 +534,4 @@ abstract class FileRepo { function findBySha1( $hash ) { return array(); } - /** - * Returns the file namespace string - * @return string - */ - function getFileNamespace() { - return $this->fileNamespace; - } } diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index fead30c6cb..a6773e11ec 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -94,7 +94,7 @@ class ForeignAPIRepo extends FileRepo { function getImageInfo( $title, $time = false ) { return $this->queryImage( array( - 'titles' => $this->getFileNamespace() . ':' . $title->getText(), + 'titles' => 'Image:' . $title->getText(), 'iiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime' ) ); } -- 2.20.1