MediaWiki
1.29.1
|
Base class for file repositories. More...
Public Member Functions | |
__construct (array $info=null) | |
backendSupportsUnicodePaths () | |
canTransformVia404 () | |
Returns true if the repository can transform files via a 404 handler. More... | |
checkRedirect (Title $title) | |
Checks if there is a redirect named as $title. More... | |
cleanDir ( $dir) | |
Deletes a directory if empty. More... | |
cleanupBatch (array $files, $flags=0) | |
Deletes a batch of files. More... | |
cleanupDeletedBatch (array $storageKeys) | |
Delete files in the deleted directory if they are not referenced in the filearchive table. More... | |
concatenate (array $srcPaths, $dstPath, $flags=0) | |
Concatenate a list of temporary files into a target file location. More... | |
delete ( $srcRel, $archiveRel) | |
Move a file to the deletion archive. More... | |
deleteBatch (array $sourceDestPairs) | |
Move a group of files to the deletion archive. More... | |
enumFiles ( $callback) | |
Call a callback function for every public regular file in the repository. More... | |
fileExists ( $file) | |
Checks existence of a a file. More... | |
fileExistsBatch (array $files) | |
Checks existence of an array of files. More... | |
findBySha1 ( $hash) | |
Get an array or iterator of file objects for files that have a given SHA-1 content hash. More... | |
findBySha1s (array $hashes) | |
Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashes. More... | |
findFile ( $title, $options=[]) | |
Find an instance of the named file created at the specified time Returns false if the file does not exist. More... | |
findFileFromKey ( $sha1, $options=[]) | |
Find an instance of the file with this key, created at the specified time Returns false if the file does not exist. More... | |
findFiles (array $items, $flags=0) | |
Find many files at once. More... | |
findFilesByPrefix ( $prefix, $limit) | |
Return an array of files where the name starts with $prefix. More... | |
freeTemp ( $virtualUrl) | |
Remove a temporary file or mark it for garbage collection. More... | |
getBackend () | |
Get the file backend instance. More... | |
getDeletedHashPath ( $key) | |
Get a relative path for a deletion archive key, e.g. More... | |
getDescriptionRenderUrl ( $name, $lang=null) | |
Get the URL of the content-only fragment of the description page. More... | |
getDescriptionStylesheetUrl () | |
Get the URL of the stylesheet to apply to description pages. More... | |
getDescriptionUrl ( $name) | |
Get the URL of an image description page. More... | |
getDisplayName () | |
Get the human-readable name of the repo. More... | |
getErrorCleanupFunction () | |
Get a callback function to use for cleaning error message parameters. More... | |
getFileProps ( $virtualUrl) | |
Get properties of a file with a given virtual URL/storage path. More... | |
getFileSha1 ( $virtualUrl) | |
Get the sha1 (base 36) of a file with a given virtual URL/storage path. More... | |
getFileSize ( $virtualUrl) | |
Get the size of a file with a given virtual URL/storage path. More... | |
getFileTimestamp ( $virtualUrl) | |
Get the timestamp of a file with a given virtual URL/storage path. More... | |
getHashLevels () | |
Get the number of hash directory levels. More... | |
getHashPath ( $name) | |
Get a relative path including trailing slash, e.g. More... | |
getInfo () | |
Return information about the repository. More... | |
getLocalCacheKey () | |
Get a key for this repo in the local cache domain. More... | |
getLocalCopy ( $virtualUrl) | |
Get a local FS copy of a file with a given virtual URL/storage path. More... | |
getLocalReference ( $virtualUrl) | |
Get a local FS file with a given virtual URL/storage path. More... | |
getName () | |
Get the name of this repository, as specified by $info['name]' to the constructor. More... | |
getNameFromTitle (Title $title) | |
Get the name of a file from its title object. More... | |
getReadOnlyReason () | |
Get an explanatory message if this repo is read-only. More... | |
getRootDirectory () | |
Get the public zone root storage directory of the repository. More... | |
getSharedCacheKey () | |
Get a key on the primary cache for this repository. More... | |
getTempHashPath ( $suffix) | |
Get a relative path including trailing slash, e.g. More... | |
getTempRepo () | |
Get a temporary private FileRepo associated with this repo. More... | |
getThumbScriptUrl () | |
Get the URL of thumb.php. More... | |
getUploadStash (User $user=null) | |
Get an UploadStash associated with this repo. More... | |
getVirtualUrl ( $suffix=false) | |
Get a URL referring to this repository, with the private mwrepo protocol. More... | |
getZonePath ( $zone) | |
Get the storage path corresponding to one of the zones. More... | |
getZoneUrl ( $zone, $ext=null) | |
Get the URL corresponding to one of the four basic zones. More... | |
hasSha1Storage () | |
Returns whether or not storage is SHA-1 based. More... | |
invalidateImageRedirect (Title $title) | |
Invalidates image redirect cache related to that image Doesn't do anything for repositories that don't support image redirects. More... | |
isLocal () | |
Returns true if this the local file repository. More... | |
makeUrl ( $query='', $entry='index') | |
Make an url to this repo. More... | |
nameForThumb ( $name) | |
Get the portion of the file that contains the origin file name. More... | |
newFatal ( $message) | |
Create a new fatal error. More... | |
newFile ( $title, $time=false) | |
Create a new File object from the local repository. More... | |
newGood ( $value=null) | |
Create a new good result. More... | |
paranoidClean ( $param) | |
Path disclosure protection function. More... | |
passThrough ( $param) | |
Path disclosure protection function. More... | |
publish ( $src, $dstRel, $archiveRel, $flags=0, array $options=[]) | |
Copy or move a file either from a storage path, virtual URL, or file system path, into this repository at the specified destination location. More... | |
publishBatch (array $ntuples, $flags=0) | |
Publish a batch of files. More... | |
quickCleanDir ( $dir) | |
Deletes a directory if empty. More... | |
quickImport ( $src, $dst, $options=null) | |
Import a file from the local file system into the repo. More... | |
quickImportBatch (array $triples) | |
Import a batch of files from the local file system into the repo. More... | |
quickPurge ( $path) | |
Purge a file from the repo. More... | |
quickPurgeBatch (array $paths) | |
Purge a batch of files from the repo. More... | |
resolveVirtualUrl ( $url) | |
Get the backend storage path corresponding to a virtual URL. More... | |
store ( $srcPath, $dstZone, $dstRel, $flags=0) | |
Store a file to a given destination. More... | |
storeBatch (array $triplets, $flags=0) | |
Store a batch of files. More... | |
storeTemp ( $originalName, $srcPath) | |
Pick a random name in the temp zone and store a file to it. More... | |
streamFile ( $virtualUrl, $headers=[]) | |
Attempt to stream a file with the given virtual URL/storage path. More... | |
streamFileWithStatus ( $virtualUrl, $headers=[], $optHeaders=[]) | |
Attempt to stream a file with the given virtual URL/storage path. More... | |
supportsSha1URLs () | |
Returns whether or not repo supports having originals SHA-1s in the thumb URLs. More... | |
validateFilename ( $filename) | |
Determine if a relative path is valid, i.e. More... | |
Static Public Member Functions | |
static | isVirtualUrl ( $url) |
Determine if a string is an mwrepo:// URL. More... | |
Public Attributes | |
int | $descriptionCacheExpiry |
bool | $fetchDescription |
Whether to fetch commons image description pages and display them on the local wiki. More... | |
const | DELETE_SOURCE = 1 |
const | NAME_AND_TIME_ONLY = 1 |
const | OVERWRITE = 2 |
const | OVERWRITE_SAME = 4 |
const | SKIP_LOCKING = 8 |
Protected Member Functions | |
assertWritableRepo () | |
Throw an exception if this repo is read-only by design. More... | |
enumFilesInStorage ( $callback) | |
Call a callback function for every public file in the repository. More... | |
getZoneLocation ( $zone) | |
The the storage container and base path of a zone. More... | |
initDirectory ( $dir) | |
Creates a directory with the appropriate zone permissions. More... | |
initZones ( $doZones=[]) | |
Check if a single zone or list of zones is defined for usage. More... | |
resolveToStoragePath ( $path) | |
If a path is a virtual URL, resolve it to a storage path. More... | |
Static Protected Member Functions | |
static | getHashPathForLevel ( $name, $levels) |
Protected Attributes | |
int | $abbrvThreshold |
File names over this size will use the short form of thumbnail names. More... | |
string | $articleUrl |
Equivalent to $wgArticlePath, e.g. More... | |
FileBackend | $backend |
int | $deletedHashLevels |
The number of directory levels for hash-based division of deleted files. More... | |
string | $descBaseUrl |
URL of image description pages, e.g. More... | |
string | $favicon |
The URL of the repo's favicon, if any. More... | |
array | $fileFactory = [ 'UnregisteredLocalFile', 'newFromTitle' ] |
callable Override these in the base class More... | |
array | $fileFactoryKey = false |
callable|bool Override these in the base class More... | |
int | $hashLevels |
The number of directory levels for hash-based division of files. More... | |
bool | $hasSha1Storage = false |
bool | $initialCapital |
Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames implicitly start with a capital letter. More... | |
bool | $isPrivate |
Whether all zones should be private (e.g. More... | |
array | $oldFileFactory = false |
callable|bool Override these in the base class More... | |
array | $oldFileFactoryKey = false |
callable|bool Override these in the base class More... | |
string | $pathDisclosureProtection = 'simple' |
May be 'paranoid' to remove all parameters from error messages, 'none' to leave the paths in unchanged, or 'simple' to replace paths with placeholders. More... | |
string | $scriptDirUrl |
URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g. More... | |
string | $scriptExtension |
Script extension of the MediaWiki installation, equivalent to the old $wgScriptExtension, e.g. More... | |
bool | $supportsSha1URLs = false |
string | $thumbScriptUrl |
URL of thumb.php. More... | |
string | $thumbUrl |
The base thumbnail URL. More... | |
bool | $transformVia404 |
Whether to skip media file transformation on parse and rely on a 404 handler instead. More... | |
string false | $url |
Public zone URL. More... | |
array | $zones = [] |
Map of zones to config. More... | |
Base class for file repositories.
Definition at line 37 of file FileRepo.php.
FileRepo::__construct | ( | array | $info = null | ) |
array | null | $info |
MWException |
Reimplemented in LocalRepo.
Definition at line 139 of file FileRepo.php.
References $hashLevels, as, MWNamespace\isCapitalized(), name, NS_FILE, FileBackendGroup\singleton(), and supportsSha1URLs().
|
protected |
Throw an exception if this repo is read-only by design.
This does not and should not check getReadOnlyReason().
MWException |
Reimplemented in ForeignAPIRepo, ForeignDBRepo, ForeignDBViaLBRepo, and NullRepo.
Definition at line 1881 of file FileRepo.php.
Referenced by cleanDir(), cleanupBatch(), cleanupDeletedBatch(), concatenate(), delete(), deleteBatch(), freeTemp(), publish(), publishBatch(), LocalRepo\skipWriteOperationIfSha1(), store(), storeBatch(), and storeTemp().
FileRepo::backendSupportsUnicodePaths | ( | ) |
Definition at line 311 of file FileRepo.php.
References FileBackend\ATTR_UNICODE_PATHS, and getBackend().
FileRepo::canTransformVia404 | ( | ) |
Returns true if the repository can transform files via a 404 handler.
Definition at line 619 of file FileRepo.php.
References $transformVia404.
FileRepo::checkRedirect | ( | Title | $title | ) |
Checks if there is a redirect named as $title.
If there is, return the title object. If not, return false. STUB
Reimplemented in LocalRepo.
Definition at line 1746 of file FileRepo.php.
Referenced by findFile().
FileRepo::cleanDir | ( | $dir | ) |
Deletes a directory if empty.
string | $dir | Virtual URL (or storage path) of directory to clean |
Definition at line 1337 of file FileRepo.php.
References $dir, $status, assertWritableRepo(), and newGood().
FileRepo::cleanupBatch | ( | array | $files, |
$flags = 0 |
|||
) |
Deletes a batch of files.
Each file can be a (zone, rel) pair, virtual url, storage path. It will try to delete each file, but ignores any errors that may occur.
array | $files | List of files to delete |
int | $flags | Bitwise combination of the following flags: self::SKIP_LOCKING Skip any file locking when doing the deletions |
Reimplemented in LocalRepo.
Definition at line 917 of file FileRepo.php.
References $flags, $path, $status, as, assertWritableRepo(), getZonePath(), list, newGood(), resolveToStoragePath(), and true.
FileRepo::cleanupDeletedBatch | ( | array | $storageKeys | ) |
Delete files in the deleted directory if they are not referenced in the filearchive table.
STUB
array | $storageKeys |
Reimplemented in LocalRepo.
Definition at line 1470 of file FileRepo.php.
References assertWritableRepo().
FileRepo::concatenate | ( | array | $srcPaths, |
$dstPath, | |||
$flags = 0 |
|||
) |
Concatenate a list of temporary files into a target file location.
array | $srcPaths | Ordered list of source virtual URLs/storage paths |
string | $dstPath | Target file system path |
int | $flags | Bitwise combination of the following flags: self::DELETE_SOURCE Delete the source files on success |
Definition at line 1112 of file FileRepo.php.
References $flags, $params, $source, $status, as, assertWritableRepo(), newGood(), quickPurgeBatch(), and resolveToStoragePath().
FileRepo::delete | ( | $srcRel, | |
$archiveRel | |||
) |
Move a file to the deletion archive.
If no valid deletion archive exists, this may either delete the file or throw an exception, depending on the preference of the repository
mixed | $srcRel | Relative path for the file to be deleted |
mixed | $archiveRel | Relative path for the archive location. Relative to a private archive directory. |
Reimplemented in LocalRepo.
Definition at line 1388 of file FileRepo.php.
References assertWritableRepo(), and deleteBatch().
FileRepo::deleteBatch | ( | array | $sourceDestPairs | ) |
Move a group of files to the deletion archive.
If no valid deletion archive is configured, this may either delete the file or throw an exception, depending on the preference of the repository.
The overwrite policy is determined by the repository – currently LocalRepo assumes a naming scheme in the deleted zone based on content hash, as opposed to the public zone which is assumed to be unique.
array | $sourceDestPairs | Array of source/destination pairs. Each element is a two-element array containing the source file path relative to the public root in the first element, and the archive file path relative to the deleted zone root in the second element. |
MWException |
Reimplemented in LocalRepo.
Definition at line 1411 of file FileRepo.php.
References $backend, $status, as, assertWritableRepo(), FileBackend\doOperations(), getZonePath(), initDirectory(), initZones(), list, newFatal(), newGood(), true, and validateFilename().
Referenced by delete().
FileRepo::enumFiles | ( | $callback | ) |
Call a callback function for every public regular file in the repository.
This only acts on the current version of files, not any old versions. May use either the database or the filesystem.
callable | $callback |
Reimplemented in ForeignAPIRepo.
Definition at line 1631 of file FileRepo.php.
References enumFilesInStorage().
|
protected |
Call a callback function for every public file in the repository.
May use either the database or the filesystem.
callable | $callback |
Definition at line 1642 of file FileRepo.php.
References $hashLevels, $name, $path, as, and getZonePath().
Referenced by enumFiles().
FileRepo::fileExists | ( | $file | ) |
Checks existence of a a file.
string | $file | Virtual URL (or storage path) of file to check |
Definition at line 1353 of file FileRepo.php.
References fileExistsBatch().
Referenced by UploadStashFile\__construct(), publishBatch(), and PurgeChangedFiles\purgeFromArchiveTable().
FileRepo::fileExistsBatch | ( | array | $files | ) |
Checks existence of an array of files.
array | $files | Virtual URLs (or storage paths) of files to check |
Reimplemented in ForeignAPIRepo.
Definition at line 1365 of file FileRepo.php.
References $path, as, and resolveToStoragePath().
Referenced by fileExists().
FileRepo::findBySha1 | ( | $hash | ) |
Get an array or iterator of file objects for files that have a given SHA-1 content hash.
STUB
string | $hash | SHA-1 hash |
Reimplemented in LocalRepo, and ForeignAPIRepo.
Definition at line 570 of file FileRepo.php.
Referenced by findBySha1s().
FileRepo::findBySha1s | ( | array | $hashes | ) |
Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashes.
array | $hashes | An array of hashes |
Reimplemented in LocalRepo.
Definition at line 581 of file FileRepo.php.
References $hashes, as, captcha-old\count, and findBySha1().
FileRepo::findFile | ( | $title, | |
$options = [] |
|||
) |
Find an instance of the named file created at the specified time Returns false if the file does not exist.
Repositories not supporting version control should return false if the time is specified.
Title | string | $title | Title object or string |
array | $options | Associative array of options: time: requested time for a specific file version, or false for the current version. An image object will be returned which was created at the specified time (which may be archived or current). ignoreRedirect: If true, do not follow file redirects private: If true, return restricted (deleted) files if the current user is allowed to view them. Otherwise, such files will not be found. If a User object, use that user instead of the current. latest: If true, load from the latest available data into File objects |
Definition at line 420 of file FileRepo.php.
References $flags, $options, $time, $title, checkRedirect(), File\DELETED_FILE, newFile(), File\normalizeTitle(), and NS_FILE.
Referenced by findFiles().
FileRepo::findFileFromKey | ( | $sha1, | |
$options = [] |
|||
) |
Find an instance of the file with this key, created at the specified time Returns false if the file does not exist.
Repositories not supporting version control should return false if the time is specified.
string | $sha1 | Base 36 SHA-1 hash |
array | $options | Option array, same as findFile(). |
Definition at line 533 of file FileRepo.php.
References $options, $time, and File\DELETED_FILE.
FileRepo::findFiles | ( | array | $items, |
$flags = 0 |
|||
) |
Find many files at once.
array | $items | An array of titles, or an array of findFile() options with the "title" option giving the title. Example: |
$findItem = [ 'title' => $title, 'private' => true ]; $findBatch = [ $findItem ]; $repo->findFiles( $findBatch );
No title should appear in $items twice, as the result use titles as keys
int | $flags | Supports:
|
Reimplemented in LocalRepo.
Definition at line 496 of file FileRepo.php.
References $flags, $options, $title, as, findFile(), and File\normalizeTitle().
FileRepo::findFilesByPrefix | ( | $prefix, | |
$limit | |||
) |
Return an array of files where the name starts with $prefix.
STUB
string | $prefix | The prefix to search for |
int | $limit | The maximum amount of files to return |
Reimplemented in LocalRepo.
Definition at line 601 of file FileRepo.php.
FileRepo::freeTemp | ( | $virtualUrl | ) |
Remove a temporary file or mark it for garbage collection.
string | $virtualUrl | The virtual URL returned by FileRepo::storeTemp() |
Definition at line 1090 of file FileRepo.php.
References assertWritableRepo(), getVirtualUrl(), quickPurge(), and wfDebug().
FileRepo::getBackend | ( | ) |
Get the file backend instance.
Use this function wisely.
Definition at line 215 of file FileRepo.php.
References $backend.
Referenced by backendSupportsUnicodePaths(), UploadStashCleanup\doOperations(), ForeignAPIRepo\getThumbUrlFromCache(), LocalFile\publishTo(), and PurgeChangedFiles\purgeFromArchiveTable().
FileRepo::getDeletedHashPath | ( | $key | ) |
Get a relative path for a deletion archive key, e.g.
s/z/a/ for sza251lrxrc1jad41h5mgilp8nysje52.jpg
string | $key |
MWException |
Definition at line 1482 of file FileRepo.php.
References $deletedHashLevels, and $path.
Referenced by LocalRepo\cleanupDeletedBatch(), and PurgeChangedFiles\getDeletedPath().
FileRepo::getDescriptionRenderUrl | ( | $name, | |
$lang = null |
|||
) |
Get the URL of the content-only fragment of the description page.
For MediaWiki this means action=render. This should only be called by the repository's file class, since it may return invalid results. User code should use File::getDescriptionText().
string | $name | Name of image to fetch |
string | $lang | Language to fetch it in, if any. |
Definition at line 776 of file FileRepo.php.
References $lang, $name, $query, getDescriptionUrl(), makeUrl(), wfAppendQuery(), and wfUrlencode().
FileRepo::getDescriptionStylesheetUrl | ( | ) |
Get the URL of the stylesheet to apply to description pages.
Definition at line 801 of file FileRepo.php.
References Skin\getDynamicStylesheetQuery(), makeUrl(), and wfArrayToCgi().
FileRepo::getDescriptionUrl | ( | $name | ) |
Get the URL of an image description page.
May return false if it is unknown or not applicable. In general this should only be called by the File class, since it may return invalid results for certain kinds of repositories. Use File::getDescriptionUrl() in user code.
In particular, it uses the article paths as specified to the repository constructor, whereas local repositories use the local Title functions.
string | $name |
Definition at line 742 of file FileRepo.php.
References $name, makeUrl(), and wfUrlencode().
Referenced by getDescriptionRenderUrl().
FileRepo::getDisplayName | ( | ) |
Get the human-readable name of the repo.
Definition at line 1765 of file FileRepo.php.
References $wgSitename, global, isLocal(), name, and wfMessageFallback().
Referenced by getInfo(), ForeignAPIRepo\getThumbError(), and ImagePage\printSharedImageText().
FileRepo::getErrorCleanupFunction | ( | ) |
Get a callback function to use for cleaning error message parameters.
Definition at line 1680 of file FileRepo.php.
Referenced by newFatal(), and newGood().
FileRepo::getFileProps | ( | $virtualUrl | ) |
Get properties of a file with a given virtual URL/storage path.
Properties should ultimately be obtained via FSFile::getProps().
string | $virtualUrl |
Reimplemented in ForeignAPIRepo, and MockLocalRepo.
Definition at line 1544 of file FileRepo.php.
References getLocalReference(), MimeMagic\singleton(), and true.
FileRepo::getFileSha1 | ( | $virtualUrl | ) |
Get the sha1 (base 36) of a file with a given virtual URL/storage path.
string | $virtualUrl |
Definition at line 1586 of file FileRepo.php.
References $path, and resolveToStoragePath().
Referenced by PurgeChangedFiles\getDeletedPath(), and LocalFile\publishTo().
FileRepo::getFileSize | ( | $virtualUrl | ) |
Get the size of a file with a given virtual URL/storage path.
string | $virtualUrl |
Definition at line 1574 of file FileRepo.php.
References $path, and resolveToStoragePath().
FileRepo::getFileTimestamp | ( | $virtualUrl | ) |
Get the timestamp of a file with a given virtual URL/storage path.
string | $virtualUrl |
Definition at line 1562 of file FileRepo.php.
References $path, and resolveToStoragePath().
FileRepo::getHashLevels | ( | ) |
Get the number of hash directory levels.
Definition at line 700 of file FileRepo.php.
References $hashLevels.
FileRepo::getHashPath | ( | $name | ) |
Get a relative path including trailing slash, e.g.
f/fa/ If the repo is not hashed, returns an empty string
string | $name | Name of file |
Definition at line 659 of file FileRepo.php.
References $name, and getHashPathForLevel().
Referenced by UnregisteredLocalFile\__construct(), ForeignAPIRepo\getThumbUrlFromCache(), and storeTemp().
|
staticprotected |
string | $name | |
int | $levels |
Definition at line 681 of file FileRepo.php.
Referenced by getHashPath(), and getTempHashPath().
FileRepo::getInfo | ( | ) |
Return information about the repository.
Reimplemented in LocalRepo, ForeignAPIRepo, ForeignDBRepo, and ForeignDBViaLBRepo.
Definition at line 1890 of file FileRepo.php.
References $ret, as, getDisplayName(), getName(), getZoneUrl(), and isLocal().
Referenced by ForeignDBViaLBRepo\getInfo(), and ForeignDBRepo\getInfo().
FileRepo::getLocalCacheKey | ( | ) |
Get a key for this repo in the local cache domain.
These cache keys are not shared with remote instances of the repo. The parameters are the parts of the key, as for wfMemcKey().
Definition at line 1820 of file FileRepo.php.
References $args, and getName().
Referenced by LocalRepo\checkRedirect(), ForeignAPIRepo\getThumbUrlFromCache(), and ForeignAPIRepo\httpGetCached().
FileRepo::getLocalCopy | ( | $virtualUrl | ) |
Get a local FS copy of a file with a given virtual URL/storage path.
Temporary files may be purged when the file object falls out of scope.
string | $virtualUrl |
Reimplemented in MockLocalRepo.
Definition at line 1517 of file FileRepo.php.
References $path, and resolveToStoragePath().
FileRepo::getLocalReference | ( | $virtualUrl | ) |
Get a local FS file with a given virtual URL/storage path.
The file is either an original or a copy. It should not be changed. Temporary files may be purged when the file object falls out of scope.
string | $virtualUrl |
Reimplemented in MockLocalRepo.
Definition at line 1531 of file FileRepo.php.
References $path, and resolveToStoragePath().
Referenced by getFileProps().
FileRepo::getName | ( | ) |
Get the name of this repository, as specified by $info['name]' to the constructor.
Definition at line 709 of file FileRepo.php.
References $name.
Referenced by getInfo(), getLocalCacheKey(), and isLocal().
FileRepo::getNameFromTitle | ( | Title | $title | ) |
Get the name of a file from its title object.
Title | $title |
Definition at line 629 of file FileRepo.php.
References $name, $title, $wgContLang, global, MWNamespace\isCapitalized(), and NS_FILE.
Referenced by UnregisteredLocalFile\__construct(), and LocalRepo\findFiles().
FileRepo::getReadOnlyReason | ( | ) |
Get an explanatory message if this repo is read-only.
This checks if an administrator disabled writes to the backend.
Definition at line 225 of file FileRepo.php.
Referenced by LocalFile\publishTo().
FileRepo::getRootDirectory | ( | ) |
Get the public zone root storage directory of the repository.
Definition at line 648 of file FileRepo.php.
References getZonePath().
Referenced by UnregisteredLocalFile\__construct().
FileRepo::getSharedCacheKey | ( | ) |
Get a key on the primary cache for this repository.
Returns false if the repository's cache is not accessible at this site. The parameters are the parts of the key, as for wfMemcKey().
STUB
Reimplemented in LocalRepo, ForeignDBRepo, and ForeignDBViaLBRepo.
Definition at line 1809 of file FileRepo.php.
FileRepo::getTempHashPath | ( | $suffix | ) |
Get a relative path including trailing slash, e.g.
f/fa/ If the repo is not hashed, returns an empty string
string | $suffix | Basename of file from FileRepo::storeTemp() |
Definition at line 670 of file FileRepo.php.
References $name, and getHashPathForLevel().
FileRepo::getTempRepo | ( | ) |
Get a temporary private FileRepo associated with this repo.
Files will be created in the temp zone of this repo. It will have the same backend as this repo.
Reimplemented in TempFileRepo.
Definition at line 1835 of file FileRepo.php.
FileRepo::getThumbScriptUrl | ( | ) |
Get the URL of thumb.php.
Definition at line 610 of file FileRepo.php.
References $thumbScriptUrl.
FileRepo::getUploadStash | ( | User | $user = null | ) |
Get an UploadStash associated with this repo.
User | $user |
Definition at line 1870 of file FileRepo.php.
References $user.
FileRepo::getVirtualUrl | ( | $suffix = false | ) |
Get a URL referring to this repository, with the private mwrepo protocol.
The suffix, if supplied, is considered to be unencoded, and will be URL-encoded before being returned.
string | bool | $suffix |
Definition at line 266 of file FileRepo.php.
Referenced by freeTemp(), and storeTemp().
|
protected |
The the storage container and base path of a zone.
string | $zone |
Definition at line 349 of file FileRepo.php.
Referenced by getZonePath().
FileRepo::getZonePath | ( | $zone | ) |
Get the storage path corresponding to one of the zones.
string | $zone |
Reimplemented in ForeignAPIRepo.
Definition at line 363 of file FileRepo.php.
References $base, getZoneLocation(), and list.
Referenced by UploadStashFile\__construct(), cleanupBatch(), LocalRepo\cleanupDeletedBatch(), deleteBatch(), enumFilesInStorage(), getRootDirectory(), initZones(), publishBatch(), resolveVirtualUrl(), and storeBatch().
FileRepo::getZoneUrl | ( | $zone, | |
$ext = null |
|||
) |
Get the URL corresponding to one of the four basic zones.
string | $zone | One of: public, deleted, temp, thumb |
string | null | $ext | Optional file extension |
Reimplemented in ForeignAPIRepo.
Definition at line 282 of file FileRepo.php.
References $ext, $thumbUrl, and $url.
Referenced by getInfo().
FileRepo::hasSha1Storage | ( | ) |
Returns whether or not storage is SHA-1 based.
Definition at line 1915 of file FileRepo.php.
References $hasSha1Storage.
Referenced by LocalRepo\__construct(), LocalRepo\cleanupDeletedBatch(), LocalFile\publishTo(), and LocalRepo\skipWriteOperationIfSha1().
|
protected |
Creates a directory with the appropriate zone permissions.
Callers are responsible for doing read-only and "writable repo" checks.
string | $dir | Virtual URL (or storage path) of directory to clean |
Definition at line 1311 of file FileRepo.php.
References $dir, $params, $path, $status, list, newGood(), resolveToStoragePath(), FileBackend\splitStoragePath(), and true.
Referenced by deleteBatch(), publishBatch(), quickImportBatch(), and storeBatch().
|
protected |
Check if a single zone or list of zones is defined for usage.
array | $doZones | Only do a particular zones |
MWException |
Definition at line 236 of file FileRepo.php.
References $status, array(), as, getZonePath(), and newGood().
Referenced by deleteBatch(), and publishBatch().
FileRepo::invalidateImageRedirect | ( | Title | $title | ) |
Invalidates image redirect cache related to that image Doesn't do anything for repositories that don't support image redirects.
STUB
Reimplemented in LocalRepo.
Definition at line 1757 of file FileRepo.php.
FileRepo::isLocal | ( | ) |
Returns true if this the local file repository.
Definition at line 1797 of file FileRepo.php.
References getName().
Referenced by getDisplayName(), and getInfo().
|
static |
Determine if a string is an mwrepo:// URL.
string | $url |
Definition at line 254 of file FileRepo.php.
References $url.
Referenced by UploadStashFile\__construct(), RepoGroup\getFileProps(), LocalFile\publishTo(), and resolveToStoragePath().
FileRepo::makeUrl | ( | $query = '' , |
|
$entry = 'index' |
|||
) |
Make an url to this repo.
string | $query | Query string to append |
string | $entry | Entry point; defaults to index |
Definition at line 720 of file FileRepo.php.
References $ext, $query, and wfAppendQuery().
Referenced by getDescriptionRenderUrl(), getDescriptionStylesheetUrl(), getDescriptionUrl(), and ForeignAPIRepo\httpGetCached().
FileRepo::nameForThumb | ( | $name | ) |
Get the portion of the file that contains the origin file name.
If that name is too long, then the name "thumbnail.<ext>" will be given.
string | $name |
Definition at line 1783 of file FileRepo.php.
References $ext, $name, and FileBackend\extensionFromPath().
FileRepo::newFatal | ( | $message | ) |
Create a new fatal error.
string | $message |
Definition at line 1718 of file FileRepo.php.
References $status, and getErrorCleanupFunction().
Referenced by deleteBatch(), publishBatch(), and storeBatch().
FileRepo::newFile | ( | $title, | |
$time = false |
|||
) |
Create a new File object from the local repository.
Title | string | $title | Title object or string |
bool | string | $time | Time at which the image was uploaded. If this is specified, the returned object will be an instance of the repository's old file class instead of a current file. Repositories not supporting version control should return false if this parameter is set. |
Reimplemented in ForeignAPIRepo.
Definition at line 387 of file FileRepo.php.
References $time, $title, and File\normalizeTitle().
Referenced by FindOrphanedFiles\checkFiles(), findFile(), and LocalRepo\findFiles().
FileRepo::newGood | ( | $value = null | ) |
Create a new good result.
null | string | $value |
Definition at line 1731 of file FileRepo.php.
References $status, $value, getErrorCleanupFunction(), and StatusValue\newGood().
Referenced by cleanDir(), cleanupBatch(), LocalRepo\cleanupDeletedBatch(), concatenate(), deleteBatch(), initDirectory(), initZones(), publishBatch(), quickCleanDir(), quickImportBatch(), quickPurgeBatch(), storeBatch(), and streamFileWithStatus().
FileRepo::paranoidClean | ( | $param | ) |
Path disclosure protection function.
string | $param |
Definition at line 1698 of file FileRepo.php.
FileRepo::passThrough | ( | $param | ) |
Path disclosure protection function.
string | $param |
Definition at line 1708 of file FileRepo.php.
FileRepo::publish | ( | $src, | |
$dstRel, | |||
$archiveRel, | |||
$flags = 0 , |
|||
array | $options = [] |
||
) |
Copy or move a file either from a storage path, virtual URL, or file system path, into this repository at the specified destination location.
Returns a Status object. On success, the value contains "new" or "archived", to indicate whether the file was new with that name.
Options to $options include:
string | FSFile | $src | The source file system path, storage path, or URL |
string | $dstRel | The destination relative path |
string | $archiveRel | The relative path where the existing file is to be archived, if there is one. Relative to the public zone root. |
int | $flags | Bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source file should be deleted if possible |
array | $options | Optional additional parameters |
Reimplemented in LocalRepo.
Definition at line 1161 of file FileRepo.php.
References $flags, $options, $status, assertWritableRepo(), and publishBatch().
Referenced by LocalFile\publishTo().
FileRepo::publishBatch | ( | array | $ntuples, |
$flags = 0 |
|||
) |
Publish a batch of files.
array | $ntuples | (source, dest, archive) triplets or (source, dest, archive, options) 4-tuples as per publish(). |
int | $flags | Bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source files should be deleted if possible |
MWException |
Reimplemented in LocalRepo.
Definition at line 1190 of file FileRepo.php.
References $backend, $flags, $options, $status, as, assertWritableRepo(), FileBackend\doOperations(), fileExists(), getZonePath(), initDirectory(), initZones(), FileBackend\isStoragePath(), list, newFatal(), newGood(), resolveToStoragePath(), true, and validateFilename().
Referenced by publish().
FileRepo::quickCleanDir | ( | $dir | ) |
|
final |
Import a file from the local file system into the repo.
This does no locking nor journaling and overrides existing files. This function can be used to write to otherwise read-only foreign repos. This is intended for copying generated thumbnails into the repo.
string | FSFile | $src | Source file system path, storage path, or virtual URL |
string | $dst | Virtual URL or storage path |
array | string | null | $options | An array consisting of a key named headers listing extra headers. If a string, taken as content-disposition header. (Support for array of options new in 1.23) |
Definition at line 957 of file FileRepo.php.
References $options, and quickImportBatch().
Referenced by LocalFile\publishTo(), and storeTemp().
FileRepo::quickImportBatch | ( | array | $triples | ) |
Import a batch of files from the local file system into the repo.
This does no locking nor journaling and overrides existing files. This function can be used to write to otherwise read-only foreign repos. This is intended for copying generated thumbnails into the repo.
All path parameters may be a file system path, storage path, or virtual URL. When "headers" are given they are used as HTTP headers if supported.
array | $triples | List of (source path or FSFile, destination path, disposition) |
Definition at line 1000 of file FileRepo.php.
References $status, as, initDirectory(), FileBackend\isStoragePath(), list, newGood(), and resolveToStoragePath().
Referenced by quickImport().
|
final |
Purge a file from the repo.
This does no locking nor journaling. This function can be used to write to otherwise read-only foreign repos. This is intended for purging thumbnails.
string | $path | Virtual URL or storage path |
Definition at line 969 of file FileRepo.php.
References $path, and quickPurgeBatch().
Referenced by freeTemp().
FileRepo::quickPurgeBatch | ( | array | $paths | ) |
Purge a batch of files from the repo.
This function can be used to write to otherwise read-only foreign repos. This does no locking nor journaling and is intended for purging thumbnails.
array | $paths | List of virtual URLs or storage paths |
Definition at line 1045 of file FileRepo.php.
References $path, $status, as, newGood(), resolveToStoragePath(), and true.
Referenced by concatenate(), and quickPurge().
|
protected |
If a path is a virtual URL, resolve it to a storage path.
Otherwise, just return the path as it is.
string | $path |
MWException |
Definition at line 1502 of file FileRepo.php.
References $path, isVirtualUrl(), and resolveVirtualUrl().
Referenced by cleanupBatch(), concatenate(), fileExistsBatch(), getFileSha1(), getFileSize(), getFileTimestamp(), getLocalCopy(), getLocalReference(), initDirectory(), publishBatch(), quickImportBatch(), quickPurgeBatch(), storeBatch(), and streamFileWithStatus().
FileRepo::resolveVirtualUrl | ( | $url | ) |
Get the backend storage path corresponding to a virtual URL.
Use this function wisely.
string | $url |
MWException |
Definition at line 323 of file FileRepo.php.
References $base, $url, captcha-old\count, getZonePath(), list, and name.
Referenced by UploadStashFile\__construct(), and resolveToStoragePath().
FileRepo::store | ( | $srcPath, | |
$dstZone, | |||
$dstRel, | |||
$flags = 0 |
|||
) |
Store a file to a given destination.
string | $srcPath | Source file system path, storage path, or virtual URL |
string | $dstZone | Destination zone |
string | $dstRel | Destination relative path |
int | $flags | Bitwise combination of the following flags: self::OVERWRITE Overwrite an existing destination file instead of failing self::OVERWRITE_SAME Overwrite the file if the destination exists and has the same contents as the source self::SKIP_LOCKING Skip any file locking when doing the store |
Reimplemented in LocalRepo.
Definition at line 823 of file FileRepo.php.
References $flags, $status, assertWritableRepo(), and storeBatch().
FileRepo::storeBatch | ( | array | $triplets, |
$flags = 0 |
|||
) |
Store a batch of files.
array | $triplets | (src, dest zone, dest rel) triplets as per store() |
int | $flags | Bitwise combination of the following flags: self::OVERWRITE Overwrite an existing destination file instead of failing self::OVERWRITE_SAME Overwrite the file if the destination exists and has the same contents as the source self::SKIP_LOCKING Skip any file locking when doing the store |
MWException |
Reimplemented in LocalRepo.
Definition at line 846 of file FileRepo.php.
References $backend, $flags, $status, as, assertWritableRepo(), FileBackend\doOperations(), getZonePath(), initDirectory(), FileBackend\isStoragePath(), list, newFatal(), newGood(), OVERWRITE, OVERWRITE_SAME, resolveToStoragePath(), true, validateFilename(), and wfDebug().
Referenced by store().
FileRepo::storeTemp | ( | $originalName, | |
$srcPath | |||
) |
Pick a random name in the temp zone and store a file to it.
Returns a Status object with the file Virtual URL in the value, file can later be disposed using FileRepo::freeTemp().
string | $originalName | The base name of the file as specified by the user. The file extension will be maintained. |
string | $srcPath | The current location of the file. |
Definition at line 1070 of file FileRepo.php.
References assertWritableRepo(), getHashPath(), MWTimestamp\getInstance(), getVirtualUrl(), and quickImport().
FileRepo::streamFile | ( | $virtualUrl, | |
$headers = [] |
|||
) |
Attempt to stream a file with the given virtual URL/storage path.
string | $virtualUrl | |
array | $headers | Additional HTTP headers to send on success |
Definition at line 1619 of file FileRepo.php.
References streamFileWithStatus().
FileRepo::streamFileWithStatus | ( | $virtualUrl, | |
$headers = [] , |
|||
$optHeaders = [] |
|||
) |
Attempt to stream a file with the given virtual URL/storage path.
string | $virtualUrl | |
array | $headers | Additional HTTP headers to send on success |
array | $optHeaders | HTTP request headers (if-modified-since, range, ...) |
Definition at line 1601 of file FileRepo.php.
References $params, $path, $status, newGood(), and resolveToStoragePath().
Referenced by streamFile().
FileRepo::supportsSha1URLs | ( | ) |
Returns whether or not repo supports having originals SHA-1s in the thumb URLs.
Definition at line 1923 of file FileRepo.php.
References $supportsSha1URLs.
Referenced by __construct().
FileRepo::validateFilename | ( | $filename | ) |
Determine if a relative path is valid, i.e.
not blank or involving directory traveral
string | $filename |
Definition at line 1667 of file FileRepo.php.
References FileBackend\isPathTraversalFree().
Referenced by UploadStashFile\__construct(), deleteBatch(), ForeignAPIRepo\getThumbUrlFromCache(), publishBatch(), and storeBatch().
|
protected |
File names over this size will use the short form of thumbnail names.
Short thumbnail names only have the width, parameters, and the extension.
Definition at line 118 of file FileRepo.php.
|
protected |
Equivalent to $wgArticlePath, e.g.
https://en.wikipedia.org/wiki/$1
Definition at line 86 of file FileRepo.php.
|
protected |
Definition at line 59 of file FileRepo.php.
Referenced by LocalRepo\cleanupDeletedBatch(), deleteBatch(), getBackend(), ForeignAPIRepo\getThumbUrlFromCache(), publishBatch(), and storeBatch().
|
protected |
The number of directory levels for hash-based division of deleted files.
Definition at line 112 of file FileRepo.php.
Referenced by getDeletedHashPath().
|
protected |
URL of image description pages, e.g.
https://en.wikipedia.org/wiki/File:
Definition at line 74 of file FileRepo.php.
int FileRepo::$descriptionCacheExpiry |
Definition at line 50 of file FileRepo.php.
|
protected |
The URL of the repo's favicon, if any.
Definition at line 121 of file FileRepo.php.
bool FileRepo::$fetchDescription |
Whether to fetch commons image description pages and display them on the local wiki.
Definition at line 47 of file FileRepo.php.
|
protected |
callable Override these in the base class
Definition at line 127 of file FileRepo.php.
callable|bool Override these in the base class
Definition at line 131 of file FileRepo.php.
|
protected |
The number of directory levels for hash-based division of files.
Definition at line 109 of file FileRepo.php.
Referenced by __construct(), enumFilesInStorage(), and getHashLevels().
|
protected |
Definition at line 53 of file FileRepo.php.
Referenced by hasSha1Storage().
|
protected |
Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames implicitly start with a capital letter.
The current implementation may give incorrect description page links when the local $wgCapitalLinks and initialCapital are mismatched.
Definition at line 93 of file FileRepo.php.
|
protected |
Whether all zones should be private (e.g.
private wiki repo)
Definition at line 124 of file FileRepo.php.
callable|bool Override these in the base class
Definition at line 129 of file FileRepo.php.
callable|bool Override these in the base class
Definition at line 133 of file FileRepo.php.
May be 'paranoid' to remove all parameters from error messages, 'none' to leave the paths in unchanged, or 'simple' to replace paths with placeholders.
Default for LocalRepo is 'simple'.
Definition at line 100 of file FileRepo.php.
|
protected |
URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g.
Definition at line 79 of file FileRepo.php.
|
protected |
Script extension of the MediaWiki installation, equivalent to the old $wgScriptExtension, e.g.
.php5 defaults to .php
Definition at line 83 of file FileRepo.php.
|
protected |
Definition at line 56 of file FileRepo.php.
Referenced by supportsSha1URLs().
|
protected |
|
protected |
The base thumbnail URL.
Defaults to "<url>/thumb".
Definition at line 106 of file FileRepo.php.
Referenced by getZoneUrl(), and ForeignAPIRepo\getZoneUrl().
|
protected |
Whether to skip media file transformation on parse and rely on a 404 handler instead.
Definition at line 69 of file FileRepo.php.
Referenced by canTransformVia404().
Public zone URL.
Definition at line 103 of file FileRepo.php.
Referenced by getZoneUrl(), ForeignAPIRepo\getZoneUrl(), ForeignAPIRepo\httpGet(), ForeignAPIRepo\httpGetCached(), isVirtualUrl(), and resolveVirtualUrl().
|
protected |
Map of zones to config.
Definition at line 62 of file FileRepo.php.
const FileRepo::DELETE_SOURCE = 1 |
Definition at line 38 of file FileRepo.php.
Referenced by UploadFromChunks\concatenateChunks(), and LocalFile\publishTo().
const FileRepo::NAME_AND_TIME_ONLY = 1 |
Definition at line 43 of file FileRepo.php.
Referenced by LocalRepo\findFiles().
const FileRepo::OVERWRITE = 2 |
Definition at line 39 of file FileRepo.php.
Referenced by MigrateFileRepoLayoutTest\setUp(), storeBatch(), and StoreBatchTest\storecohort().
const FileRepo::OVERWRITE_SAME = 4 |
Definition at line 40 of file FileRepo.php.
Referenced by RevDelFileList\doPreCommitUpdates(), LocalFileRestoreBatch\execute(), LocalFileMoveBatch\execute(), storeBatch(), and StoreBatchTest\storecohort().
const FileRepo::SKIP_LOCKING = 8 |
Definition at line 41 of file FileRepo.php.