wiki.techinc.nl/includes/filerepo
Gergő Tisza 9bd9289c6c filerepo: Improve identification of ForeignAPIRepo requests
These requests are usually sent to a wiki operated by a different
organization so UA etiquette is important.
* Add the site's URL (the URL of the main page, more specifically)
  as a contact address.
* Add the site's URL as a referer as well.

Considered but not done:
* Use $wgEmergencyContact as the contact part of the UA. It's not
  guaranteed to be set correctly, while the main page URL always
  exists and will usually be enough to pinpoint the wiki (except
  maybe in some intranet scenarios).
* Include information about the user making the request. Would
  be a privacy risk + probably useless due to caching.
* Include information about the page the request is for. Would
  require lots of refactoring (making the patch harder to
  backport) or relying on the context title (which might be
  fragile), and in any case probably unreliable due to caching,
  and doesn't seem very relevant to the operator of the foreign
  site.

Bug: T400881
Change-Id: I968fac6ee0ebbc5a2bd3244f57851eb64125c93d
2025-08-18 21:02:23 +00:00
..
file Updated wikimedia/scoped-callback from 4.0.0 to 5.0.0 2024-11-10 00:30:11 +00:00
Hook
AuthenticatedFileEntryPoint.php Fix img_auth message logic 2024-11-14 01:05:30 +00:00
FileBackendDBRepoWrapper.php FileRepo: Add support for the new Shellbox large file feature 2024-10-29 02:50:07 +00:00
FileRepo.php FileRepo: Add support for the new Shellbox large file feature 2024-10-29 02:50:07 +00:00
ForeignAPIRepo.php filerepo: Improve identification of ForeignAPIRepo requests 2025-08-18 21:02:23 +00:00
ForeignDBRepo.php
ForeignDBViaLBRepo.php
IForeignRepoWithDB.php
IForeignRepoWithMWApi.php
LocalRepo.php Use explicit nullable type on parameter arguments 2024-10-16 20:58:33 +02:00
NullRepo.php
README.md
RepoGroup.php Add namespace to remaining parts of Wikimedia\Mime and Wikimedia\Stats 2024-09-27 16:19:10 -04:00
TempFileRepo.php
Thumbnail404EntryPoint.php
ThumbnailEntryPoint.php filerepo: No exception on redirect without width in ThumbnailEntryPoint 2025-04-29 20:01:15 +00:00

FileRepo Architecture

Some quick notes on the file/repository architecture.

Functionality is, as always, driven by data model.

  • The repository object stores configuration information about a file storage method.

  • The file object is a process-local cache of information about a particular file.

Thus the file object is the primary public entry point for obtaining information about files, since access via the file object can be cached, whereas access via the repository should not be cached.

Functions which can act on any file specified in their parameters typically find their place either in the repository object, where reference to repository-specific configuration is needed, or in static members of File or FileRepo, where no such configuration is needed.

File objects are generated by a factory function from the repository. The repository thus has full control over the behavior of its subsidiary file class, since it can subclass the file class and override functionality at its whim. Thus there is no need for the File subclass to query its parent repository for information about repository-class-dependent behavior -- the file subclass is generally fully aware of the static preferences of its repository. Limited exceptions can be made to this rule to permit sharing of functions, or perhaps even entire classes, between repositories.

These rules alone still do lead to some ambiguity -- it may not be clear whether to implement some functionality in a repository function with a filename parameter, or in the file object itself.

So we introduce the following rule: the file subclass is smarter than the repository subclass. The repository should in general provide a minimal API needed to access the storage backend efficiently.

In particular, note that I have not implemented any database access in LocalRepo.php. LocalRepo provides only file access, and LocalFile provides database access and higher-level functions such as cache management.

Tim Starling, June 2007