MediaWiki REL1_31
README
Go to the documentation of this file.
1Some quick notes on the file/repository architecture.
2
3Functionality is, as always, driven by data model.
4
5* The repository object stores configuration information about a file storage
6 method.
7
8* The file object is a process-local cache of information about a particular
9 file.
10
11Thus the file object is the primary public entry point for obtaining information
12about files, since access via the file object can be cached, whereas access via
13the repository should not be cached.
14
15Functions which can act on any file specified in their parameters typically find
16their place either in the repository object, where reference to
17repository-specific configuration is needed, or in static members of File or
18FileRepo, where no such configuration is needed.
19
20File objects are generated by a factory function from the repository. The
21repository thus has full control over the behavior of its subsidiary file
22class, since it can subclass the file class and override functionality at its
23whim. Thus there is no need for the File subclass to query its parent repository
24for information about repository-class-dependent behavior -- the file subclass
25is generally fully aware of the static preferences of its repository. Limited
26exceptions can be made to this rule to permit sharing of functions, or perhaps
27even entire classes, between repositories.
28
29These rules alone still do lead to some ambiguity -- it may not be clear whether
30to implement some functionality in a repository function with a filename
31parameter, or in the file object itself.
32
33So we introduce the following rule: the file subclass is smarter than the
34repository subclass. The repository should in general provide a minimal API
35needed to access the storage backend efficiently.
36
37In particular, note that I have not implemented any database access in
38LocalRepo.php. LocalRepo provides only file access, and LocalFile provides
39database access and higher-level functions such as cache management.
40
41Tim Starling, June 2007