From: Aaron Schulz Date: Wed, 21 Dec 2011 21:29:16 +0000 (+0000) Subject: * FU r106752: unbreak urls to ForeignAPIRepo file thumbnails. FileRepo no longer... X-Git-Tag: 1.31.0-rc.0~25824 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=29a6b9e7139a24b5b6ebe0b50c2df7e737078eb2;p=lhc%2Fweb%2Fwiklou.git * FU r106752: unbreak urls to ForeignAPIRepo file thumbnails. FileRepo no longer uses bogus /thumb default for the thumnail URL when the public root URL wasn't even set. This was making ForeignAPIRepo not set it since it saw that it was already set. * Cleaned up and added some missing sanity checks for scriptDirUrl member in FileRepo. Made some related documentation tweaks. * Removed pointless getRepo() call in File. --- diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 1bebf4acd7..6a48d88a87 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -42,9 +42,6 @@ class FileRepo { function __construct( $info ) { // Required settings $this->name = $info['name']; - $this->url = isset( $info['url'] ) - ? $info['url'] - : false; // a subclass will need to set the URL (e.g. ForeignAPIRepo) if ( $info['backend'] instanceof FileBackendBase ) { $this->backend = $info['backend']; // useful for testing } else { @@ -67,9 +64,14 @@ class FileRepo { $this->initialCapital = isset( $info['initialCapital'] ) ? $info['initialCapital'] : MWNamespace::isCapitalized( NS_FILE ); - $this->thumbUrl = isset( $info['thumbUrl'] ) - ? $info['thumbUrl'] - : "{$this->url}/thumb"; + $this->url = isset( $info['url'] ) + ? $info['url'] + : false; // a subclass may set the URL (e.g. ForeignAPIRepo) + if ( isset( $info['thumbUrl'] ) ) { + $this->thumbUrl = $info['thumbUrl']; + } else { + $this->thumbUrl = $this->url ? "{$this->url}/thumb" : false; + } $this->hashLevels = isset( $info['hashLevels'] ) ? $info['hashLevels'] : 2; @@ -414,7 +416,7 @@ class FileRepo { /** * Get the public root URL of the repository * - * @return string + * @return string|false */ public function getRootUrl() { return $this->url; @@ -526,11 +528,14 @@ class FileRepo { * * @param $query mixed Query string to append * @param $entry string Entry point; defaults to index - * @return string + * @return string|false */ public function makeUrl( $query = '', $entry = 'index' ) { - $ext = isset( $this->scriptExtension ) ? $this->scriptExtension : '.php'; - return wfAppendQuery( "{$this->scriptDirUrl}/{$entry}{$ext}", $query ); + if ( isset( $this->scriptDirUrl ) ) { + $ext = isset( $this->scriptExtension ) ? $this->scriptExtension : '.php'; + return wfAppendQuery( "{$this->scriptDirUrl}/{$entry}{$ext}", $query ); + } + return false; } /** @@ -603,13 +608,14 @@ class FileRepo { /** * Get the URL of the stylesheet to apply to description pages * - * @return string + * @return string|false */ public function getDescriptionStylesheetUrl() { - if ( $this->scriptDirUrl ) { + if ( isset( $this->scriptDirUrl ) ) { return $this->makeUrl( 'title=MediaWiki:Filepage.css&' . wfArrayToCGI( Skin::getDynamicStylesheetQuery() ) ); } + return false; } /** diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index 9fc552e294..a241d6bd8d 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -1293,8 +1293,7 @@ abstract class File { * @return bool */ function isLocal() { - $repo = $this->getRepo(); - return $repo && $repo->isLocal(); + return $this->repo && $this->repo->isLocal(); } /**