From cf8c776bed7b66891fd0296a4f35960f2fde3b7e Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 20 Aug 2012 16:39:55 -0700 Subject: [PATCH] [FileRepo] Improved support for private wiki repos. Change-Id: I8beda76767c15bbf1f6dd5d23e6a5624db267404 --- includes/DefaultSettings.php | 6 ++++-- includes/filerepo/FileRepo.php | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 20c97a03c2..3ea35d53fc 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -385,7 +385,9 @@ $wgImgAuthPublicTest = true; * some remote repos. * - thumbDir The base thumbnail directory. Defaults to "/thumb". * - thumbUrl The base thumbnail URL. Defaults to "/thumb". - * + * - isPrivate Set this if measures should always be taken to keep the files private. + * One should not trust this to assure that the files are not web readable; + * the server configuration should be done manually depending on the backend. * * These settings describe a foreign MediaWiki installation. They are optional, and will be ignored * for local repositories: @@ -2323,7 +2325,7 @@ $wgVariantArticlePath = false; $wgLoginLanguageSelector = false; /** - * When translating messages with wfMessage(), it is not always clear what + * When translating messages with wfMessage(), it is not always clear what * should be considered UI messages and what should be content messages. * * For example, for the English Wikipedia, there should be only one 'mainpage', diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 1563a58658..3159077df1 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -113,10 +113,9 @@ class FileRepo { ? $info['deletedHashLevels'] : $this->hashLevels; $this->transformVia404 = !empty( $info['transformVia404'] ); - $this->zones = isset( $info['zones'] ) - ? $info['zones'] - : array(); + $this->isPrivate = !empty( $info['isPrivate'] ); // Give defaults for the basic zones... + $this->zones = isset( $info['zones'] ) ? $info['zones'] : array(); foreach ( array( 'public', 'thumb', 'temp', 'deleted' ) as $zone ) { if ( !isset( $this->zones[$zone]['container'] ) ) { $this->zones[$zone]['container'] = "{$this->name}-{$zone}"; @@ -1163,7 +1162,7 @@ class FileRepo { list( $b, $container, $r ) = FileBackend::splitStoragePath( $path ); $params = array( 'dir' => $path ); - if ( $container === $this->zones['deleted']['container'] ) { + if ( $this->isPrivate || $container === $this->zones['deleted']['container'] ) { # Take all available measures to prevent web accessibility of new deleted # directories, in case the user has not configured offline storage $params = array( 'noAccess' => true, 'noListing' => true ) + $params; -- 2.20.1