MediaWiki  REL1_24
README
Go to the documentation of this file.
00001 Some quick notes on the file/repository architecture.
00002 
00003 Functionality is, as always, driven by data model.
00004 
00005 * The repository object stores configuration information about a file storage
00006   method.
00007 
00008 * The file object is a process-local cache of information about a particular
00009   file.
00010 
00011 Thus the file object is the primary public entry point for obtaining information
00012 about files, since access via the file object can be cached, whereas access via
00013 the repository should not be cached.
00014 
00015 Functions which can act on any file specified in their parameters typically find
00016 their place either in the repository object, where reference to
00017 repository-specific configuration is needed, or in static members of File or
00018 FileRepo, where no such configuration is needed.
00019 
00020 File objects are generated by a factory function from the repository. The
00021 repository thus has full control over the behavior of its subsidiary file
00022 class, since it can subclass the file class and override functionality at its
00023 whim. Thus there is no need for the File subclass to query its parent repository
00024 for information about repository-class-dependent behavior -- the file subclass
00025 is generally fully aware of the static preferences of its repository. Limited
00026 exceptions can be made to this rule to permit sharing of functions, or perhaps
00027 even entire classes, between repositories.
00028 
00029 These rules alone still do lead to some ambiguity -- it may not be clear whether
00030 to implement some functionality in a repository function with a filename
00031 parameter, or in the file object itself.
00032 
00033 So we introduce the following rule: the file subclass is smarter than the
00034 repository subclass. The repository should in general provide a minimal API
00035 needed to access the storage backend efficiently.
00036 
00037 In particular, note that I have not implemented any database access in
00038 LocalRepo.php. LocalRepo provides only file access, and LocalFile provides
00039 database access and higher-level functions such as cache management.
00040 
00041 Tim Starling, June 2007