Merge "Convert Special:DeletedContributions to use OOUI."
[lhc/web/wiklou.git] / includes / filerepo / FSRepo.php
1 <?php
2 /**
3 * A repository for files accessible via the local filesystem.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup FileRepo
22 */
23
24 /**
25 * A repository for files accessible via the local filesystem.
26 * Does not support database access or registration.
27 *
28 * This is a mostly a legacy class. New uses should not be added.
29 *
30 * @ingroup FileRepo
31 * @deprecated since 1.19
32 */
33 class FSRepo extends FileRepo {
34 /**
35 * @param array $info
36 * @throws MWException
37 */
38 function __construct( array $info ) {
39 if ( !isset( $info['backend'] ) ) {
40 // B/C settings...
41 $directory = $info['directory'];
42 $deletedDir = isset( $info['deletedDir'] )
43 ? $info['deletedDir']
44 : false;
45 $thumbDir = isset( $info['thumbDir'] )
46 ? $info['thumbDir']
47 : "{$directory}/thumb";
48 $transcodedDir = isset( $info['transcodedDir'] )
49 ? $info['transcodedDir']
50 : "{$directory}/transcoded";
51 $fileMode = isset( $info['fileMode'] )
52 ? $info['fileMode']
53 : 0644;
54
55 $repoName = $info['name'];
56 // Get the FS backend configuration
57 $backend = new FSFileBackend( [
58 'name' => $info['name'] . '-backend',
59 'wikiId' => wfWikiID(),
60 'lockManager' => LockManagerGroup::singleton( wfWikiID() )->get( 'fsLockManager' ),
61 'containerPaths' => [
62 "{$repoName}-public" => "{$directory}",
63 "{$repoName}-temp" => "{$directory}/temp",
64 "{$repoName}-thumb" => $thumbDir,
65 "{$repoName}-transcoded" => $transcodedDir,
66 "{$repoName}-deleted" => $deletedDir
67 ],
68 'fileMode' => $fileMode,
69 'tmpDirectory' => wfTempDir()
70 ] );
71 // Update repo config to use this backend
72 $info['backend'] = $backend;
73 }
74
75 parent::__construct( $info );
76
77 if ( !( $this->backend instanceof FSFileBackend ) ) {
78 throw new MWException( "FSRepo only supports FSFileBackend." );
79 }
80 }
81 }