MediaWiki
REL1_22
|
Base class for file repositories. More...
Public Member Functions | |
__construct (array $info=null) | |
canTransformVia404 () | |
Returns true if the repository can transform files via a 404 handler. | |
checkRedirect (Title $title) | |
Checks if there is a redirect named as $title. | |
cleanDir ($dir) | |
Deletes a directory if empty. | |
cleanupBatch (array $files, $flags=0) | |
Deletes a batch of files. | |
cleanupDeletedBatch (array $storageKeys) | |
Delete files in the deleted directory if they are not referenced in the filearchive table. | |
concatenate (array $srcPaths, $dstPath, $flags=0) | |
Concatenate a list of temporary files into a target file location. | |
delete ($srcRel, $archiveRel) | |
Move a file to the deletion archive. | |
deleteBatch (array $sourceDestPairs) | |
Move a group of files to the deletion archive. | |
enumFiles ($callback) | |
Call a callback function for every public regular file in the repository. | |
fileExists ($file) | |
Checks existence of a a file. | |
fileExistsBatch (array $files) | |
Checks existence of an array of files. | |
findBySha1 ($hash) | |
Get an array or iterator of file objects for files that have a given SHA-1 content hash. | |
findBySha1s (array $hashes) | |
Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashes. | |
findFile ($title, $options=array()) | |
Find an instance of the named file created at the specified time Returns false if the file does not exist. | |
findFileFromKey ($sha1, $options=array()) | |
Find an instance of the file with this key, created at the specified time Returns false if the file does not exist. | |
findFiles (array $items) | |
Find many files at once. | |
findFilesByPrefix ($prefix, $limit) | |
Return an array of files where the name starts with $prefix. | |
freeTemp ($virtualUrl) | |
Remove a temporary file or mark it for garbage collection. | |
getBackend () | |
Get the file backend instance. | |
getDeletedHashPath ($key) | |
Get a relative path for a deletion archive key, e.g. | |
getDescriptionRenderUrl ($name, $lang=null) | |
Get the URL of the content-only fragment of the description page. | |
getDescriptionStylesheetUrl () | |
Get the URL of the stylesheet to apply to description pages. | |
getDescriptionUrl ($name) | |
Get the URL of an image description page. | |
getDisplayName () | |
Get the human-readable name of the repo. | |
getErrorCleanupFunction () | |
Get a callback function to use for cleaning error message parameters. | |
getFileProps ($virtualUrl) | |
Get properties of a file with a given virtual URL/storage path. | |
getFileSha1 ($virtualUrl) | |
Get the sha1 (base 36) of a file with a given virtual URL/storage path. | |
getFileSize ($virtualUrl) | |
Get the size of a file with a given virtual URL/storage path. | |
getFileTimestamp ($virtualUrl) | |
Get the timestamp of a file with a given virtual URL/storage path. | |
getHashLevels () | |
Get the number of hash directory levels. | |
getHashPath ($name) | |
Get a relative path including trailing slash, e.g. | |
getInfo () | |
Return information about the repository. | |
getLocalCacheKey () | |
Get a key for this repo in the local cache domain. | |
getLocalCopy ($virtualUrl) | |
Get a local FS copy of a file with a given virtual URL/storage path. | |
getLocalReference ($virtualUrl) | |
Get a local FS file with a given virtual URL/storage path. | |
getName () | |
Get the name of this repository, as specified by $info['name]' to the constructor. | |
getNameFromTitle (Title $title) | |
Get the name of an image from its title object. | |
getReadOnlyReason () | |
Get an explanatory message if this repo is read-only. | |
getRootDirectory () | |
Get the public zone root storage directory of the repository. | |
getRootUrl () | |
Get the public root URL of the repository. | |
getSharedCacheKey () | |
Get a key on the primary cache for this repository. | |
getTempHashPath ($suffix) | |
Get a relative path including trailing slash, e.g. | |
getTempRepo () | |
Get an temporary FileRepo associated with this repo. | |
getThumbScriptUrl () | |
Get the URL of thumb.php. | |
getUploadStash (User $user=null) | |
Get an UploadStash associated with this repo. | |
getVirtualUrl ($suffix=false) | |
Get a URL referring to this repository, with the private mwrepo protocol. | |
getZoneHandlerUrl ($zone) | |
Get the thumb zone URL configured to be handled by scripts like thumb_handler.php. | |
getZonePath ($zone) | |
Get the storage path corresponding to one of the zones. | |
getZoneUrl ($zone, $ext=null) | |
Get the URL corresponding to one of the four basic zones. | |
invalidateImageRedirect (Title $title) | |
Invalidates image redirect cache related to that image Doesn't do anything for repositories that don't support image redirects. | |
isLocal () | |
Returns true if this the local file repository. | |
makeUrl ($query= '', $entry= 'index') | |
Make an url to this repo. | |
nameForThumb ($name) | |
Get the portion of the file that contains the origin file name. | |
newFatal ($message) | |
Create a new fatal error. | |
newFile ($title, $time=false) | |
Create a new File object from the local repository. | |
newGood ($value=null) | |
Create a new good result. | |
paranoidClean ($param) | |
Path disclosure protection function. | |
passThrough ($param) | |
Path disclosure protection function. | |
publish ($srcPath, $dstRel, $archiveRel, $flags=0, array $options=array()) | |
Copy or move a file either from a storage path, virtual URL, or file system path, into this repository at the specified destination location. | |
publishBatch (array $ntuples, $flags=0) | |
Publish a batch of files. | |
quickCleanDir ($dir) | |
Deletes a directory if empty. | |
quickImport ($src, $dst, $disposition=null) | |
Import a file from the local file system into the repo. | |
quickImportBatch (array $triples) | |
Import a batch of files from the local file system into the repo. | |
quickPurge ($path) | |
Purge a file from the repo. | |
quickPurgeBatch (array $paths) | |
Purge a batch of files from the repo. | |
resolveVirtualUrl ($url) | |
Get the backend storage path corresponding to a virtual URL. | |
store ($srcPath, $dstZone, $dstRel, $flags=0) | |
Store a file to a given destination. | |
storeBatch (array $triplets, $flags=0) | |
Store a batch of files. | |
storeTemp ($originalName, $srcPath) | |
Pick a random name in the temp zone and store a file to it. | |
streamFile ($virtualUrl, $headers=array()) | |
Attempt to stream a file with the given virtual URL/storage path. | |
validateFilename ($filename) | |
Determine if a relative path is valid, i.e. | |
Static Public Member Functions | |
static | isVirtualUrl ($url) |
Determine if a string is an mwrepo:// URL. | |
Public Attributes | |
$articleUrl | |
$deletedHashLevels | |
$descBaseUrl | |
$descriptionCacheExpiry | |
$fetchDescription | |
$fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' ) | |
Factory functions for creating new files Override these in the base class. | |
$fileFactoryKey = false | |
$hashLevels | |
$initialCapital | |
$oldFileFactory = false | |
$oldFileFactoryKey = false | |
$pathDisclosureProtection = 'simple' | |
$scriptDirUrl | |
$scriptExtension | |
$thumbScriptUrl | |
$thumbUrl | |
$transformVia404 | |
$url | |
const | DELETE_SOURCE = 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. | |
enumFilesInStorage ($callback) | |
Call a callback function for every public file in the repository. | |
getZoneLocation ($zone) | |
The the storage container and base path of a zone. | |
initDirectory ($dir) | |
Creates a directory with the appropriate zone permissions. | |
initZones ($doZones=array()) | |
Check if a single zone or list of zones is defined for usage. | |
resolveToStoragePath ($path) | |
If a path is a virtual URL, resolve it to a storage path. | |
Static Protected Member Functions | |
static | getHashPathForLevel ($name, $levels) |
Protected Attributes | |
$abbrvThreshold | |
FileBackend | $backend |
* | |
Array | $zones = array() |
Map of zones to config *. |
Base class for file repositories.
Definition at line 37 of file FileRepo.php.
FileRepo::__construct | ( | array $ | info = null | ) |
$info | array|null |
MWException |
Reimplemented in FSRepo.
Definition at line 66 of file FileRepo.php.
FileRepo::assertWritableRepo | ( | ) | [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 1716 of file FileRepo.php.
Returns true if the repository can transform files via a 404 handler.
Definition at line 527 of file FileRepo.php.
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
$title | Title of image |
Reimplemented in LocalRepo.
Definition at line 1586 of file FileRepo.php.
FileRepo::cleanDir | ( | $ | dir | ) |
Deletes a directory if empty.
string | $dir | Virtual URL (or storage path) of directory to clean |
Definition at line 1221 of file FileRepo.php.
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 |
$flags | Integer: bitwise combination of the following flags: self::SKIP_LOCKING Skip any file locking when doing the deletions |
Definition at line 829 of file FileRepo.php.
FileRepo::cleanupDeletedBatch | ( | array $ | storageKeys | ) |
Delete files in the deleted directory if they are not referenced in the filearchive table.
STUB
Reimplemented in LocalRepo.
Definition at line 1348 of file FileRepo.php.
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 |
$flags | Integer: bitwise combination of the following flags: self::DELETE_SOURCE Delete the source files |
Definition at line 1004 of file FileRepo.php.
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
$srcRel | Mixed: relative path for the file to be deleted |
$archiveRel | Mixed: relative path for the archive location. Relative to a private archive directory. |
Definition at line 1267 of file FileRepo.php.
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 | 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 |
Definition at line 1290 of file FileRepo.php.
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.
$callback | Array|string |
Reimplemented in ForeignAPIRepo.
Definition at line 1477 of file FileRepo.php.
FileRepo::enumFilesInStorage | ( | $ | callback | ) | [protected] |
Call a callback function for every public file in the repository.
May use either the database or the filesystem.
$callback | Array|string |
Definition at line 1488 of file FileRepo.php.
FileRepo::fileExists | ( | $ | file | ) |
Checks existence of a a file.
string | $file | Virtual URL (or storage path) of file to check |
Definition at line 1237 of file FileRepo.php.
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 1248 of file FileRepo.php.
FileRepo::findBySha1 | ( | $ | hash | ) |
Get an array or iterator of file objects for files that have a given SHA-1 content hash.
STUB
$hash |
Reimplemented in LocalRepo, and ForeignAPIRepo.
Definition at line 469 of file FileRepo.php.
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 480 of file FileRepo.php.
FileRepo::findFile | ( | $ | title, |
$ | options = array() |
||
) |
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 | Mixed: 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.
Definition at line 353 of file FileRepo.php.
FileRepo::findFileFromKey | ( | $ | sha1, |
$ | options = array() |
||
) |
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 436 of file FileRepo.php.
FileRepo::findFiles | ( | array $ | items | ) |
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 = array( 'title' => $title, 'private' => true ); $findBatch = array( $findItem ); $repo->findFiles( $findBatch );
Definition at line 408 of file FileRepo.php.
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 499 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 983 of file FileRepo.php.
Get the file backend instance.
Use this function wisely.
Definition at line 139 of file FileRepo.php.
Referenced by ForeignAPIRepo\getThumbUrlFromCache().
FileRepo::getDeletedHashPath | ( | $ | key | ) |
Get a relative path for a deletion archive key, e.g.
s/z/a/ for sza251lrxrc1jad41h5mgilp8nysje52.jpg
$key | string |
MWException |
Definition at line 1360 of file FileRepo.php.
Referenced by LocalRepo\cleanupDeletedBatch().
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 681 of file FileRepo.php.
Get the URL of the stylesheet to apply to description pages.
Definition at line 706 of file FileRepo.php.
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.
$name | string |
Definition at line 646 of file FileRepo.php.
Get the human-readable name of the repo.
Definition at line 1604 of file FileRepo.php.
Referenced by ForeignAPIRepo\getThumbError().
Get a callback function to use for cleaning error message parameters.
Definition at line 1525 of file FileRepo.php.
FileRepo::getFileProps | ( | $ | virtualUrl | ) |
Get properties of a file with a given virtual URL/storage path.
Properties should ultimately be obtained via FSFile::getProps().
$virtualUrl | string |
Reimplemented in ForeignAPIRepo.
Definition at line 1418 of file FileRepo.php.
FileRepo::getFileSha1 | ( | $ | virtualUrl | ) |
Get the sha1 (base 36) of a file with a given virtual URL/storage path.
$virtualUrl | string |
Definition at line 1451 of file FileRepo.php.
FileRepo::getFileSize | ( | $ | virtualUrl | ) |
Get the size of a file with a given virtual URL/storage path.
$virtualUrl | string |
Definition at line 1440 of file FileRepo.php.
FileRepo::getFileTimestamp | ( | $ | virtualUrl | ) |
Get the timestamp of a file with a given virtual URL/storage path.
$virtualUrl | string |
Definition at line 1429 of file FileRepo.php.
Get the number of hash directory levels.
Definition at line 606 of file FileRepo.php.
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 566 of file FileRepo.php.
Referenced by ForeignAPIRepo\getThumbUrlFromCache().
static FileRepo::getHashPathForLevel | ( | $ | name, |
$ | levels | ||
) | [static, protected] |
Return information about the repository.
Reimplemented in ForeignAPIRepo.
Definition at line 1725 of file FileRepo.php.
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 1656 of file FileRepo.php.
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.
$virtualUrl | string |
Definition at line 1393 of file FileRepo.php.
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.
$virtualUrl | string |
Definition at line 1406 of file FileRepo.php.
Get the name of this repository, as specified by $info['name]' to the constructor.
Definition at line 615 of file FileRepo.php.
FileRepo::getNameFromTitle | ( | Title $ | title | ) |
Get the name of an image from its title object.
$title | Title |
Definition at line 537 of file FileRepo.php.
Get an explanatory message if this repo is read-only.
This checks if an administrator disabled writes to the backend.
Definition at line 149 of file FileRepo.php.
Get the public zone root storage directory of the repository.
Definition at line 555 of file FileRepo.php.
Get the public root URL of the repository.
Definition at line 509 of file FileRepo.php.
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 1645 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 577 of file FileRepo.php.
Get an temporary FileRepo associated with this repo.
Files will be created in the temp zone of this repo and thumbnails in a /temp subdirectory in thumb zone of this repo. It will have the same backend as this repo.
Reimplemented in TempFileRepo.
Definition at line 1670 of file FileRepo.php.
FileRepo::getUploadStash | ( | User $ | user = null | ) |
Get an UploadStash associated with this repo.
$user | User |
Definition at line 1705 of file FileRepo.php.
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.
$suffix | string|bool |
Definition at line 189 of file FileRepo.php.
FileRepo::getZoneHandlerUrl | ( | $ | zone | ) |
Get the thumb zone URL configured to be handled by scripts like thumb_handler.php.
This is probably only useful for internal requests, such as from a fast frontend server to a slower backend server.
Large sites may use a different host name for uploads than for wikis. In any case, the wiki configuration is needed in order to use thumb.php. To avoid extracting the wiki ID from the URL path, one can configure thumb_handler.php to recognize a special path on the same host name as the wiki that is used for viewing thumbnails.
string | $zone | one of: public, deleted, temp, thumb |
Definition at line 241 of file FileRepo.php.
FileRepo::getZoneLocation | ( | $ | zone | ) | [protected] |
The the storage container and base path of a zone.
$zone | string |
Definition at line 283 of file FileRepo.php.
FileRepo::getZonePath | ( | $ | zone | ) |
Get the storage path corresponding to one of the zones.
$zone | string |
Reimplemented in ForeignAPIRepo.
Definition at line 296 of file FileRepo.php.
Referenced by LocalRepo\cleanupDeletedBatch().
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 204 of file FileRepo.php.
FileRepo::initDirectory | ( | $ | dir | ) | [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 1201 of file FileRepo.php.
FileRepo::initZones | ( | $ | doZones = array() | ) | [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 160 of file FileRepo.php.
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
$title | Title of image |
Reimplemented in LocalRepo.
Definition at line 1597 of file FileRepo.php.
Returns true if this the local file repository.
Definition at line 1633 of file FileRepo.php.
static FileRepo::isVirtualUrl | ( | $ | url | ) | [static] |
Determine if a string is an mwrepo:// URL.
$url | string |
Definition at line 177 of file FileRepo.php.
FileRepo::makeUrl | ( | $ | query = '' , |
$ | entry = 'index' |
||
) |
Make an url to this repo.
$query | mixed Query string to append | |
string | $entry | Entry point; defaults to index |
Definition at line 626 of file FileRepo.php.
Referenced by 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.
$name | string |
Definition at line 1620 of file FileRepo.php.
FileRepo::newFatal | ( | $ | message | ) |
FileRepo::newFile | ( | $ | title, |
$ | time = false |
||
) |
Create a new File object from the local repository.
$title | Mixed: Title object or string |
$time | Mixed: 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 319 of file FileRepo.php.
FileRepo::newGood | ( | $ | value = null | ) |
Create a new good result.
$value | null|string |
Definition at line 1574 of file FileRepo.php.
Referenced by LocalRepo\cleanupDeletedBatch().
FileRepo::paranoidClean | ( | $ | param | ) |
Path disclosure protection function.
$param | string |
Definition at line 1543 of file FileRepo.php.
FileRepo::passThrough | ( | $ | param | ) |
Path disclosure protection function.
$param | string |
Definition at line 1553 of file FileRepo.php.
FileRepo::publish | ( | $ | srcPath, |
$ | dstRel, | ||
$ | archiveRel, | ||
$ | flags = 0 , |
||
array $ | options = array() |
||
) |
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 FileRepoStatus object. On success, the value contains "new" or "archived", to indicate whether the file was new with that name.
Options to $options include:
string | $srcPath | 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. |
$flags | Integer: bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source file should be deleted if possible | |
array | $options | Optional additional parameters |
Definition at line 1053 of file FileRepo.php.
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(). |
$flags | Integer: bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source files should be deleted if possible |
MWException |
Definition at line 1082 of file FileRepo.php.
FileRepo::quickCleanDir | ( | $ | dir | ) |
Deletes a directory if empty.
This function can be used to write to otherwise read-only foreign repos.
string | $dir | Virtual URL (or storage path) of directory to clean |
Definition at line 890 of file FileRepo.php.
FileRepo::quickImport | ( | $ | src, |
$ | dst, | ||
$ | disposition = null |
||
) | [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 | $src | Source file system path, storage path, or virtual URL |
string | $dst | Virtual URL or storage path |
string | null | $disposition | Content-Disposition if given and supported |
Definition at line 867 of file FileRepo.php.
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 "dispositions" are given they are used as Content-Disposition if supported.
array | $triples | List of (source path, destination path, disposition) |
Definition at line 910 of file FileRepo.php.
FileRepo::quickPurge | ( | $ | path | ) | [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 879 of file FileRepo.php.
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 938 of file FileRepo.php.
FileRepo::resolveToStoragePath | ( | $ | path | ) | [protected] |
If a path is a virtual URL, resolve it to a storage path.
Otherwise, just return the path as it is.
$path | string |
MWException |
Definition at line 1379 of file FileRepo.php.
FileRepo::resolveVirtualUrl | ( | $ | url | ) |
Get the backend storage path corresponding to a virtual URL.
Use this function wisely.
$url | string |
MWException |
Definition at line 258 of file FileRepo.php.
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 |
$flags | Integer: bitwise combination of the following flags: self::DELETE_SOURCE Delete the source file after upload 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 |
Definition at line 728 of file FileRepo.php.
FileRepo::storeBatch | ( | array $ | triplets, |
$ | flags = 0 |
||
) |
Store a batch of files.
array | $triplets | (src, dest zone, dest rel) triplets as per store() |
$flags | Integer: bitwise combination of the following flags: self::DELETE_SOURCE Delete the source file after upload 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 |
Definition at line 752 of file FileRepo.php.
FileRepo::storeTemp | ( | $ | originalName, |
$ | srcPath | ||
) |
Pick a random name in the temp zone and store a file to it.
Returns a FileRepoStatus 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 963 of file FileRepo.php.
FileRepo::streamFile | ( | $ | virtualUrl, |
$ | headers = array() |
||
) |
Attempt to stream a file with the given virtual URL/storage path.
$virtualUrl | string | |
array | $headers | Additional HTTP headers to send on success |
Definition at line 1463 of file FileRepo.php.
FileRepo::validateFilename | ( | $ | filename | ) |
Determine if a relative path is valid, i.e.
not blank or involving directory traveral
$filename | string |
Definition at line 1513 of file FileRepo.php.
Referenced by ForeignAPIRepo\getThumbUrlFromCache().
FileRepo::$abbrvThreshold [protected] |
Definition at line 52 of file FileRepo.php.
FileRepo::$articleUrl |
Definition at line 47 of file FileRepo.php.
FileBackend FileRepo::$backend [protected] |
*
Definition at line 43 of file FileRepo.php.
Referenced by FSRepo\__construct(), LocalRepo\cleanupDeletedBatch(), and ForeignAPIRepo\getThumbUrlFromCache().
FileRepo::$deletedHashLevels |
Definition at line 51 of file FileRepo.php.
FileRepo::$descBaseUrl |
Definition at line 47 of file FileRepo.php.
FileRepo::$descriptionCacheExpiry |
Definition at line 50 of file FileRepo.php.
FileRepo::$fetchDescription |
Definition at line 48 of file FileRepo.php.
FileRepo::$fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' ) |
Factory functions for creating new files Override these in the base class.
Reimplemented in ForeignAPIRepo, ForeignDBRepo, LocalRepo, and ForeignDBViaLBRepo.
Definition at line 58 of file FileRepo.php.
FileRepo::$fileFactoryKey = false |
Reimplemented in LocalRepo.
Definition at line 60 of file FileRepo.php.
FileRepo::$hashLevels |
Definition at line 51 of file FileRepo.php.
FileRepo::$initialCapital |
Definition at line 48 of file FileRepo.php.
FileRepo::$oldFileFactory = false |
Reimplemented in LocalRepo.
Definition at line 59 of file FileRepo.php.
FileRepo::$oldFileFactoryKey = false |
Reimplemented in LocalRepo.
Definition at line 60 of file FileRepo.php.
FileRepo::$pathDisclosureProtection = 'simple' |
Definition at line 49 of file FileRepo.php.
FileRepo::$scriptDirUrl |
Definition at line 47 of file FileRepo.php.
FileRepo::$scriptExtension |
Definition at line 47 of file FileRepo.php.
FileRepo::$thumbScriptUrl |
Definition at line 46 of file FileRepo.php.
FileRepo::$thumbUrl |
Definition at line 50 of file FileRepo.php.
FileRepo::$transformVia404 |
Definition at line 46 of file FileRepo.php.
FileRepo::$url |
Definition at line 50 of file FileRepo.php.
Referenced by ForeignAPIRepo\httpGet(), and ForeignAPIRepo\httpGetCached().
Array FileRepo::$zones = array() [protected] |
Map of zones to config *.
Definition at line 44 of file FileRepo.php.
const FileRepo::DELETE_SOURCE = 1 |
Definition at line 38 of file FileRepo.php.
Referenced by UploadFromChunks\concatenateChunks(), and OldLocalFile\uploadOld().
const FileRepo::OVERWRITE = 2 |
Definition at line 39 of file FileRepo.php.
const FileRepo::OVERWRITE_SAME = 4 |
Definition at line 40 of file FileRepo.php.
Referenced by RevDel_FileList\doPreCommitUpdates().
const FileRepo::SKIP_LOCKING = 8 |
Definition at line 41 of file FileRepo.php.