From a51a193f85e9485f529fc0e9be4b887631ac8161 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 20 Dec 2011 18:55:50 +0000 Subject: [PATCH] FU r106752: added b/c code to FSRepo to make things easy for extensions (like ConfirmAccount) --- includes/filerepo/FSRepo.php | 44 +++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/includes/filerepo/FSRepo.php b/includes/filerepo/FSRepo.php index 8dd83335f4..f33f09e5ba 100644 --- a/includes/filerepo/FSRepo.php +++ b/includes/filerepo/FSRepo.php @@ -7,14 +7,52 @@ */ /** - * A repository for files accessible via the local filesystem. Does not support - * database access or registration. + * A repository for files accessible via the local filesystem. + * Does not support database access or registration. + * + * This is a mostly a legacy class. New uses should not be added. + * * @ingroup FileRepo * @deprecated since 1.19 */ class FSRepo extends FileRepo { - function __construct( $info ) { + function __construct( array $info ) { + if ( !isset( $info['backend'] ) ) { + // B/C settings... + $directory = $info['directory']; + $deletedDir = isset( $info['deletedDir'] ) + ? $info['deletedDir'] + : false; + $thumbDir = isset( $info['thumbDir'] ) + ? $info['thumbDir'] + : "{$directory}/thumb"; + $fileMode = isset( $info['fileMode'] ) + ? $info['fileMode'] + : 0644; + + // Get the FS backend configuration + $backend = new FSFileBackend( array( + 'name' => $info['name'] . '-backend', + 'lockManager' => 'fsLockManager', + 'containerPaths' => array( + "images-public" => "{$directory}", + "images-temp" => "{$directory}/temp", + "images-thumb" => $thumbDir, + "images-deleted" => $deletedDir + ), + 'fileMode' => $fileMode, + ) ); + // Update repo config to use this backend + $info['backend'] = $backend; + // Set "deleted" zone in repo if deletedDir is configured + if ( $deletedDir !== false ) { + $info['zones']['deleted'] = array( + 'container' => 'images-deleted', 'directory' => '' ); + } + } + parent::__construct( $info ); + if ( !( $this->backend instanceof FSFileBackend ) ) { throw new MWException( "FSRepo only supports FSFileBackend." ); } -- 2.20.1