MediaWiki
REL1_19
|
Base class for all backends associated with a particular storage medium. More...
Public Member Functions | |
clearCache (array $paths=null) | |
concatenate (array $params) | |
copyInternal (array $params) | |
Copy a file from one storage path to another in the backend. | |
createInternal (array $params) | |
Create a file in the backend with the given contents. | |
deleteInternal (array $params) | |
Delete a file at the storage path. | |
fileExists (array $params) | |
getFileContents (array $params) | |
getFileList (array $params) | |
getFileListInternal ($container, $dir, array $params) | |
Do not call this function from places outside FileBackend. | |
getFileProps (array $params) | |
getFileSha1Base36 (array $params) | |
getFileSize (array $params) | |
getFileStat (array $params) | |
getFileTimestamp (array $params) | |
getLocalReference (array $params) | |
getOperations (array $ops) | |
Return a list of FileOp objects from a list of operations. | |
isPathUsableInternal ($storagePath) | |
Check if a file can be created at a given storage path. | |
maxFileSizeInternal () | |
Get the maximum allowable file size given backend medium restrictions and basic performance constraints. | |
moveInternal (array $params) | |
Move a file from one storage path to another in the backend. | |
storeInternal (array $params) | |
Store a file into the backend from a file on disk. | |
streamFile (array $params) | |
Protected Member Functions | |
doClean (array $params) | |
doCleanInternal ($container, $dir, array $params) | |
doClearCache (array $paths=null) | |
Clears any additional stat caches for storage paths. | |
doConcatenate (array $params) | |
doCopyInternal (array $params) | |
doCreateInternal (array $params) | |
doDeleteInternal (array $params) | |
doGetFileSha1Base36 (array $params) | |
doGetFileStat (array $params) | |
doMoveInternal (array $params) | |
doOperationsInternal (array $ops, array $opts) | |
doPrepare (array $params) | |
doPrepareInternal ($container, $dir, array $params) | |
doSecure (array $params) | |
doSecureInternal ($container, $dir, array $params) | |
doStoreInternal (array $params) | |
doStreamFile (array $params) | |
fullContainerName ($container) | |
Get the full container name, including the wiki ID prefix. | |
getContainerHashLevels ($container) | |
Get the sharding config for a container. | |
getContainerShard ($container, $relPath) | |
Get the container name shard suffix for a given path. | |
getContainerSuffixes ($container) | |
Get a list of full container shard suffixes for a container. | |
resolveContainerName ($container) | |
Resolve a container name, checking if it's allowed by the backend. | |
resolveContainerPath ($container, $relStoragePath) | |
Resolve a relative storage path, checking if it's allowed by the backend. | |
resolveStoragePath ($storagePath) | |
Splits a storage path into an internal container name, an internal relative file name, and a container shard suffix. | |
resolveStoragePathReal ($storagePath) | |
Like resolveStoragePath() except null values are returned if the container is sharded and the shard could not be determined. | |
supportedOperations () | |
Get the list of supported operations and their corresponding FileOp classes. | |
trimCache () | |
Prune the inexpensive cache if it is too big to add an item. | |
trimExpensiveCache () | |
Prune the expensive cache if it is too big to add an item. | |
Static Protected Member Functions | |
static | isValidContainerName ($container) |
Check if a container name is valid. | |
Protected Attributes | |
$cache = array() | |
$expensiveCache = array() | |
$maxCacheSize = 100 | |
$maxExpensiveCacheSize = 10 | |
$maxFileSize = 1000000000 | |
$shardViaHashLevels = array() |
Base class for all backends associated with a particular storage medium.
This class defines the methods as abstract that subclasses must implement. Outside callers should *not* use functions with "Internal" in the name.
The FileBackend operations are implemented using basic functions such as storeInternal(), copyInternal(), deleteInternal() and the like. This class is also responsible for path resolution and sanitization.
Definition at line 729 of file FileBackend.php.
FileBackendStore::clearCache | ( | array $ | paths = null | ) | [final] |
Reimplemented from FileBackend.
Definition at line 1402 of file FileBackend.php.
References $path, and doClearCache().
Referenced by copyInternal(), createInternal(), deleteInternal(), doOperationsInternal(), moveInternal(), and storeInternal().
FileBackendStore::concatenate | ( | array $ | params | ) | [final] |
Reimplemented from FileBackend.
Definition at line 907 of file FileBackend.php.
References doConcatenate(), FileBackend\getScopedFileLocks(), LockManager\LOCK_UW, Status\newGood(), wfProfileIn(), and wfProfileOut().
FileBackendStore::copyInternal | ( | array $ | params | ) | [final] |
Copy a file from one storage path to another in the backend.
Do not call this function from places outside FileBackend and FileOp.
$params include: src : source storage path dst : destination storage path overwrite : overwrite any file that exists at the destination
$params | Array |
Definition at line 833 of file FileBackend.php.
References clearCache(), doCopyInternal(), wfProfileIn(), and wfProfileOut().
Referenced by doMoveInternal().
FileBackendStore::createInternal | ( | array $ | params | ) | [final] |
Create a file in the backend with the given contents.
Do not call this function from places outside FileBackend and FileOp.
$params include: content : the raw file contents dst : destination storage path overwrite : overwrite any file that exists at the destination
$params | Array |
Definition at line 775 of file FileBackend.php.
References clearCache(), doCreateInternal(), maxFileSizeInternal(), Status\newFatal(), wfProfileIn(), and wfProfileOut().
FileBackendStore::deleteInternal | ( | array $ | params | ) | [final] |
Delete a file at the storage path.
Do not call this function from places outside FileBackend and FileOp.
$params include: src : source storage path ignoreMissingSource : do nothing if the source file does not exist
$params | Array |
Definition at line 857 of file FileBackend.php.
References clearCache(), doDeleteInternal(), wfProfileIn(), and wfProfileOut().
Referenced by doMoveInternal().
FileBackendStore::doClean | ( | array $ | params | ) | [final, protected] |
Reimplemented from FileBackend.
Definition at line 1050 of file FileBackend.php.
References $dir, doCleanInternal(), getContainerSuffixes(), FileBackend\getScopedFileLocks(), LockManager\LOCK_EX, Status\newGood(), resolveStoragePath(), FileBackend\splitStoragePath(), wfDebug(), wfProfileIn(), and wfProfileOut().
FileBackendStore::doCleanInternal | ( | $ | container, |
$ | dir, | ||
array $ | params | ||
) | [protected] |
Reimplemented in SwiftFileBackend, and FSFileBackend.
Definition at line 1086 of file FileBackend.php.
References Status\newGood().
Referenced by doClean().
FileBackendStore::doClearCache | ( | array $ | paths = null | ) | [protected] |
Clears any additional stat caches for storage paths.
$paths | Array Storage paths (optional) |
Reimplemented in SwiftFileBackend, and FSFileBackend.
Definition at line 1427 of file FileBackend.php.
Referenced by clearCache().
FileBackendStore::doConcatenate | ( | array $ | params | ) | [protected] |
Definition at line 925 of file FileBackend.php.
References $ok, getLocalReference(), Status\newGood(), wfRestoreWarnings(), and wfSuppressWarnings().
Referenced by concatenate().
FileBackendStore::doCopyInternal | ( | array $ | params | ) | [abstract, protected] |
Reimplemented in SwiftFileBackend, and FSFileBackend.
Referenced by copyInternal().
FileBackendStore::doCreateInternal | ( | array $ | params | ) | [abstract, protected] |
Reimplemented in FSFileBackend, and SwiftFileBackend.
Referenced by createInternal().
FileBackendStore::doDeleteInternal | ( | array $ | params | ) | [abstract, protected] |
Reimplemented in SwiftFileBackend, and FSFileBackend.
Referenced by deleteInternal().
FileBackendStore::doGetFileSha1Base36 | ( | array $ | params | ) | [protected] |
Definition at line 1192 of file FileBackend.php.
References getLocalReference().
Referenced by getFileSha1Base36().
FileBackendStore::doGetFileStat | ( | array $ | params | ) | [abstract, protected] |
Reimplemented in SwiftFileBackend, and FSFileBackend.
Referenced by getFileStat().
FileBackendStore::doMoveInternal | ( | array $ | params | ) | [protected] |
Reimplemented in FSFileBackend.
Definition at line 893 of file FileBackend.php.
References copyInternal(), and deleteInternal().
Referenced by moveInternal().
FileBackendStore::doOperationsInternal | ( | array $ | ops, |
array $ | opts | ||
) | [protected] |
Reimplemented from FileBackend.
Definition at line 1357 of file FileBackend.php.
References FileOp\attemptBatch(), clearCache(), getOperations(), FileBackend\getScopedFileLocks(), LockManager\LOCK_EX, LockManager\LOCK_UW, Status\newGood(), wfProfileIn(), and wfProfileOut().
FileBackendStore::doPrepare | ( | array $ | params | ) | [final, protected] |
Reimplemented from FileBackend.
Definition at line 980 of file FileBackend.php.
References $dir, doPrepareInternal(), getContainerSuffixes(), Status\newGood(), resolveStoragePath(), FileBackend\splitStoragePath(), wfDebug(), wfProfileIn(), and wfProfileOut().
FileBackendStore::doPrepareInternal | ( | $ | container, |
$ | dir, | ||
array $ | params | ||
) | [protected] |
Reimplemented in FSFileBackend, and SwiftFileBackend.
Definition at line 1008 of file FileBackend.php.
References Status\newGood().
Referenced by doPrepare().
FileBackendStore::doSecure | ( | array $ | params | ) | [final, protected] |
Reimplemented from FileBackend.
Definition at line 1015 of file FileBackend.php.
References $dir, doSecureInternal(), getContainerSuffixes(), Status\newGood(), resolveStoragePath(), FileBackend\splitStoragePath(), wfDebug(), wfProfileIn(), and wfProfileOut().
FileBackendStore::doSecureInternal | ( | $ | container, |
$ | dir, | ||
array $ | params | ||
) | [protected] |
Reimplemented in SwiftFileBackend, and FSFileBackend.
Definition at line 1043 of file FileBackend.php.
References Status\newGood().
Referenced by doSecure().
FileBackendStore::doStoreInternal | ( | array $ | params | ) | [abstract, protected] |
Reimplemented in SwiftFileBackend, and FSFileBackend.
Referenced by storeInternal().
FileBackendStore::doStreamFile | ( | array $ | params | ) | [protected] |
Reimplemented in SwiftFileBackend.
Definition at line 1261 of file FileBackend.php.
References getLocalReference(), and Status\newGood().
Referenced by streamFile().
FileBackendStore::fileExists | ( | array $ | params | ) | [final] |
Reimplemented from FileBackend.
Definition at line 1093 of file FileBackend.php.
References getFileStat(), wfProfileIn(), and wfProfileOut().
Referenced by SwiftFileBackend\doCopyInternal(), SwiftFileBackend\doCreateInternal(), SwiftFileBackend\doStoreInternal(), SwiftFileBackend\getFileContents(), and SwiftFileBackend\getLocalCopy().
FileBackendStore::fullContainerName | ( | $ | container | ) | [final, protected] |
Get the full container name, including the wiki ID prefix.
$container | string |
Definition at line 1606 of file FileBackend.php.
Referenced by resolveStoragePath().
FileBackendStore::getContainerHashLevels | ( | $ | container | ) | [final, protected] |
Get the sharding config for a container.
If greater than 0, then all file storage paths within the container are required to be hashed accordingly.
$container | string |
Definition at line 1568 of file FileBackend.php.
Referenced by getContainerShard(), and getContainerSuffixes().
FileBackendStore::getContainerShard | ( | $ | container, |
$ | relPath | ||
) | [final, protected] |
Get the container name shard suffix for a given path.
Any empty suffix means the container is not sharded.
$container | string Container name |
$relStoragePath | string Storage path relative to the container |
Definition at line 1532 of file FileBackend.php.
References getContainerHashLevels().
Referenced by resolveStoragePath().
FileBackendStore::getContainerSuffixes | ( | $ | container | ) | [final, protected] |
Get a list of full container shard suffixes for a container.
$container | string |
Definition at line 1588 of file FileBackend.php.
References getContainerHashLevels(), and wfBaseConvert().
Referenced by doClean(), doPrepare(), doSecure(), and getFileList().
FileBackendStore::getFileContents | ( | array $ | params | ) |
Reimplemented from FileBackend.
Reimplemented in SwiftFileBackend.
Definition at line 1156 of file FileBackend.php.
References getLocalReference(), wfProfileIn(), wfProfileOut(), wfRestoreWarnings(), and wfSuppressWarnings().
FileBackendStore::getFileList | ( | array $ | params | ) | [final] |
Get an iterator to list out all stored files under a storage directory.
If the directory is of the form "mwstore://backend/container", then all files in the container should be listed. If the directory is of form "mwstore://backend/container/dir", then all files under that container directory should be listed. Results should be storage paths relative to the given directory.
Storage backends with eventual consistency might return stale data.
$params include: dir : storage path directory
Reimplemented from FileBackend.
Definition at line 1277 of file FileBackend.php.
References $dir, getContainerSuffixes(), getFileListInternal(), resolveStoragePath(), FileBackend\splitStoragePath(), and wfDebug().
FileBackendStore::getFileListInternal | ( | $ | container, |
$ | dir, | ||
array $ | params | ||
) | [abstract] |
Do not call this function from places outside FileBackend.
$container | string Resolved container name |
$dir | string Resolved path relative to container |
$params | Array |
Reimplemented in SwiftFileBackend, and FSFileBackend.
Referenced by getFileList().
FileBackendStore::getFileProps | ( | array $ | params | ) | [final] |
Reimplemented from FileBackend.
Definition at line 1204 of file FileBackend.php.
References getLocalReference(), FSFile\placeholderProps(), wfProfileIn(), and wfProfileOut().
FileBackendStore::getFileSha1Base36 | ( | array $ | params | ) | [final] |
Reimplemented from FileBackend.
Definition at line 1173 of file FileBackend.php.
References $path, doGetFileSha1Base36(), trimCache(), wfProfileIn(), and wfProfileOut().
FileBackendStore::getFileSize | ( | array $ | params | ) | [final] |
Reimplemented from FileBackend.
Definition at line 1113 of file FileBackend.php.
References getFileStat(), wfProfileIn(), and wfProfileOut().
FileBackendStore::getFileStat | ( | array $ | params | ) | [final] |
Reimplemented from FileBackend.
Definition at line 1123 of file FileBackend.php.
References $path, doGetFileStat(), FileBackend\normalizeStoragePath(), trimCache(), wfProfileIn(), and wfProfileOut().
Referenced by SwiftFileBackend\doGetFileSha1base36(), fileExists(), getFileSize(), getFileTimestamp(), and streamFile().
FileBackendStore::getFileTimestamp | ( | array $ | params | ) | [final] |
Reimplemented from FileBackend.
Definition at line 1103 of file FileBackend.php.
References getFileStat(), wfProfileIn(), and wfProfileOut().
FileBackendStore::getLocalReference | ( | array $ | params | ) |
Reimplemented from FileBackend.
Reimplemented in FSFileBackend.
Definition at line 1215 of file FileBackend.php.
References $path, FileBackend\getLocalCopy(), trimExpensiveCache(), wfProfileIn(), and wfProfileOut().
Referenced by doConcatenate(), doGetFileSha1Base36(), doStreamFile(), getFileContents(), and getFileProps().
FileBackendStore::getOperations | ( | array $ | ops | ) | [final] |
Return a list of FileOp objects from a list of operations.
Do not call this function from places outside FileBackend.
The result must have the same number of items as the input. An exception is thrown if an unsupported operation is requested.
$ops | Array Same format as doOperations() |
MWException |
Definition at line 1333 of file FileBackend.php.
References supportedOperations().
Referenced by doOperationsInternal().
FileBackendStore::isPathUsableInternal | ( | $ | storagePath | ) | [abstract] |
Check if a file can be created at a given storage path.
FS backends should check if the parent directory exists and the file is writable. Backends using key/value stores should check if the container exists.
$storagePath | string |
Reimplemented in FSFileBackend, and SwiftFileBackend.
static FileBackendStore::isValidContainerName | ( | $ | container | ) | [static, final, protected] |
Check if a container name is valid.
This checks for for length and illegal characters.
$container | string |
Definition at line 1460 of file FileBackend.php.
FileBackendStore::maxFileSizeInternal | ( | ) | [final] |
Get the maximum allowable file size given backend medium restrictions and basic performance constraints.
Do not call this function from places outside FileBackend and FileOp.
Definition at line 749 of file FileBackend.php.
Referenced by createInternal(), and storeInternal().
FileBackendStore::moveInternal | ( | array $ | params | ) | [final] |
Move a file from one storage path to another in the backend.
Do not call this function from places outside FileBackend and FileOp.
$params include: src : source storage path dst : destination storage path overwrite : overwrite any file that exists at the destination
$params | Array |
Definition at line 882 of file FileBackend.php.
References clearCache(), doMoveInternal(), wfProfileIn(), and wfProfileOut().
FileBackendStore::resolveContainerName | ( | $ | container | ) | [protected] |
Resolve a container name, checking if it's allowed by the backend.
This is intended for internal use, such as encoding illegal chars. Subclasses can override this to be more restrictive.
$container | string |
Definition at line 1622 of file FileBackend.php.
Referenced by resolveStoragePath().
FileBackendStore::resolveContainerPath | ( | $ | container, |
$ | relStoragePath | ||
) | [protected] |
Resolve a relative storage path, checking if it's allowed by the backend.
This is intended for internal use, such as encoding illegal chars or perhaps getting absolute paths (e.g. FS based backends). Note that the relative path may be the empty string (e.g. the path is simply to the container).
$container | string Container name |
$relStoragePath | string Storage path relative to the container |
Reimplemented in SwiftFileBackend, and FSFileBackend.
Definition at line 1636 of file FileBackend.php.
Referenced by resolveStoragePath().
FileBackendStore::resolveStoragePath | ( | $ | storagePath | ) | [final, protected] |
Splits a storage path into an internal container name, an internal relative file name, and a container shard suffix.
Any shard suffix is already appended to the internal container name. This also checks that the storage path is valid and within this backend.
If the container is sharded but a suffix could not be determined, this means that the path can only refer to a directory and can only be scanned by looking in all the container shards.
$storagePath | string |
Definition at line 1482 of file FileBackend.php.
References fullContainerName(), getContainerShard(), FileBackend\normalizeContainerPath(), resolveContainerName(), resolveContainerPath(), and FileBackend\splitStoragePath().
Referenced by doClean(), doPrepare(), doSecure(), getFileList(), and resolveStoragePathReal().
FileBackendStore::resolveStoragePathReal | ( | $ | storagePath | ) | [final, protected] |
Like resolveStoragePath() except null values are returned if the container is sharded and the shard could not be determined.
$storagePath | string |
Definition at line 1516 of file FileBackend.php.
References resolveStoragePath().
Referenced by SwiftFileBackend\doCopyInternal(), SwiftFileBackend\doCreateInternal(), SwiftFileBackend\doDeleteInternal(), SwiftFileBackend\doGetFileStat(), SwiftFileBackend\doStoreInternal(), SwiftFileBackend\doStreamFile(), SwiftFileBackend\getFileContents(), SwiftFileBackend\getLocalCopy(), SwiftFileBackend\isPathUsableInternal(), and FSFileBackend\resolveToFSPath().
FileBackendStore::storeInternal | ( | array $ | params | ) | [final] |
Store a file into the backend from a file on disk.
Do not call this function from places outside FileBackend and FileOp.
$params include: src : source path on disk dst : destination storage path overwrite : overwrite any file that exists at the destination
$params | Array |
Definition at line 804 of file FileBackend.php.
References clearCache(), doStoreInternal(), maxFileSizeInternal(), Status\newFatal(), wfProfileIn(), and wfProfileOut().
FileBackendStore::streamFile | ( | array $ | params | ) | [final] |
Reimplemented from FileBackend.
Definition at line 1234 of file FileBackend.php.
References $res, doStreamFile(), getFileStat(), Status\newGood(), StreamFile\NOT_MODIFIED, StreamFile\prepareForStream(), StreamFile\READY_STREAM, wfProfileIn(), and wfProfileOut().
FileBackendStore::supportedOperations | ( | ) | [protected] |
Get the list of supported operations and their corresponding FileOp classes.
Definition at line 1311 of file FileBackend.php.
Referenced by getOperations().
FileBackendStore::trimCache | ( | ) | [protected] |
Prune the inexpensive cache if it is too big to add an item.
Definition at line 1434 of file FileBackend.php.
Referenced by getFileSha1Base36(), and getFileStat().
FileBackendStore::trimExpensiveCache | ( | ) | [protected] |
Prune the expensive cache if it is too big to add an item.
Definition at line 1446 of file FileBackend.php.
Referenced by getLocalReference().
FileBackendStore::$cache = array() [protected] |
Definition at line 731 of file FileBackend.php.
FileBackendStore::$expensiveCache = array() [protected] |
Definition at line 734 of file FileBackend.php.
FileBackendStore::$maxCacheSize = 100 [protected] |
Definition at line 732 of file FileBackend.php.
FileBackendStore::$maxExpensiveCacheSize = 10 [protected] |
Definition at line 735 of file FileBackend.php.
FileBackendStore::$maxFileSize = 1000000000 [protected] |
Definition at line 740 of file FileBackend.php.
FileBackendStore::$shardViaHashLevels = array() [protected] |
Definition at line 738 of file FileBackend.php.