[FileRepo] Improved support for private wiki repos.
authorAaron <aschulz@wikimedia.org>
Mon, 20 Aug 2012 23:39:55 +0000 (16:39 -0700)
committerAaron <aschulz@wikimedia.org>
Mon, 20 Aug 2012 23:39:55 +0000 (16:39 -0700)
Change-Id: I8beda76767c15bbf1f6dd5d23e6a5624db267404

includes/DefaultSettings.php
includes/filerepo/FileRepo.php

index 20c97a0..3ea35d5 100644 (file)
@@ -385,7 +385,9 @@ $wgImgAuthPublicTest = true;
  *                      some remote repos.
  *   - thumbDir         The base thumbnail directory. Defaults to "<directory>/thumb".
  *   - thumbUrl         The base thumbnail URL. Defaults to "<url>/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',
index 1563a58..3159077 100644 (file)
@@ -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;