Index: trunk/phase3/includes/filerepo/FileRepo.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | var $thumbScriptUrl, $transformVia404; |
17 | 17 | var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription, $initialCapital; |
18 | 18 | var $pathDisclosureProtection = 'paranoid'; |
19 | | - var $descriptionCacheExpiry, $apiThumbCacheExpiry, $hashLevels; |
| 19 | + var $descriptionCacheExpiry, $apiThumbCacheExpiry, $hashLevels, $fileNamespace; |
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Factory functions for creating new files |
— | — | @@ -30,9 +30,10 @@ |
31 | 31 | |
32 | 32 | // Optional settings |
33 | 33 | $this->initialCapital = true; // by default |
| 34 | + $this->fileNamespace = MWNamespace::getCanonicalName( NS_FILE ); // fallback to 'File' |
34 | 35 | foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription', |
35 | 36 | 'thumbScriptUrl', 'initialCapital', 'pathDisclosureProtection', |
36 | | - 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'hashLevels' ) as $var ) |
| 37 | + 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'hashLevels', 'fileNamespace' ) as $var ) |
37 | 38 | { |
38 | 39 | if ( isset( $info[$var] ) ) { |
39 | 40 | $this->$var = $info[$var]; |
— | — | @@ -262,10 +263,10 @@ |
263 | 264 | if ( is_null( $this->descBaseUrl ) ) { |
264 | 265 | if ( !is_null( $this->articleUrl ) ) { |
265 | 266 | $this->descBaseUrl = str_replace( '$1', |
266 | | - wfUrlencode( MWNamespace::getCanonicalName( NS_FILE ) ) . ':', $this->articleUrl ); |
| 267 | + wfUrlencode( $this->getFileNamespace() ) . ':', $this->articleUrl ); |
267 | 268 | } elseif ( !is_null( $this->scriptDirUrl ) ) { |
268 | 269 | $this->descBaseUrl = $this->scriptDirUrl . '/index.php?title=' . |
269 | | - wfUrlencode( MWNamespace::getCanonicalName( NS_FILE ) ) . ':'; |
| 270 | + wfUrlencode( $this->getFileNamespace() ) . ':'; |
270 | 271 | } else { |
271 | 272 | $this->descBaseUrl = false; |
272 | 273 | } |
— | — | @@ -300,7 +301,7 @@ |
301 | 302 | function getDescriptionRenderUrl( $name ) { |
302 | 303 | if ( isset( $this->scriptDirUrl ) ) { |
303 | 304 | return $this->scriptDirUrl . '/index.php?title=' . |
304 | | - wfUrlencode( MWNamespace::getCanonicalName( NS_FILE ) . ':' . $name ) . |
| 305 | + wfUrlencode( $this->getFileNamespace() . ':' . $name ) . |
305 | 306 | '&action=render'; |
306 | 307 | } else { |
307 | 308 | $descBase = $this->getDescBaseUrl(); |
— | — | @@ -534,4 +535,11 @@ |
535 | 536 | function findBySha1( $hash ) { |
536 | 537 | return array(); |
537 | 538 | } |
| 539 | + /** |
| 540 | + * Returns the file namespace string |
| 541 | + * @return strig |
| 542 | + */ |
| 543 | + function getFileNamespace() { |
| 544 | + return $this->fileNamespace; |
| 545 | + } |
538 | 546 | } |
Index: trunk/phase3/includes/filerepo/ForeignAPIRepo.php |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | |
96 | 96 | function getImageInfo( $title, $time = false ) { |
97 | 97 | return $this->queryImage( array( |
98 | | - 'titles' => 'Image:' . $title->getText(), |
| 98 | + 'titles' => $this->getFileNamespace() . ':' . $title->getText(), |
99 | 99 | 'iiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime' ) ); |
100 | 100 | } |
101 | 101 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -388,6 +388,10 @@ |
389 | 389 | * (bug 16026) 'Revision-info' and 'revision-info-current' both accept wiki |
390 | 390 | markup now. |
391 | 391 | * (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. |
392 | 396 | |
393 | 397 | |
394 | 398 | === API changes in 1.14 === |