MediaWiki  REL1_19
FileBackendStore Class Reference

Base class for all backends associated with a particular storage medium. More...

Inheritance diagram for FileBackendStore:
Collaboration diagram for FileBackendStore:

List of all members.

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()

Detailed Description

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.

Since:
1.19

Definition at line 729 of file FileBackend.php.


Member Function Documentation

FileBackendStore::clearCache ( array $  paths = null) [final]
See also:
FileBackend::clearCache()

Reimplemented from FileBackend.

Definition at line 1402 of file FileBackend.php.

References $path, and doClearCache().

Referenced by copyInternal(), createInternal(), deleteInternal(), doOperationsInternal(), moveInternal(), and storeInternal().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::concatenate ( array $  params) [final]
See also:
FileBackend::concatenate()

Reimplemented from FileBackend.

Definition at line 907 of file FileBackend.php.

References doConcatenate(), FileBackend\getScopedFileLocks(), LockManager\LOCK_UW, Status\newGood(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

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

Parameters:
$paramsArray
Returns:
Status

Definition at line 833 of file FileBackend.php.

References clearCache(), doCopyInternal(), wfProfileIn(), and wfProfileOut().

Referenced by doMoveInternal().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
$paramsArray
Returns:
Status

Definition at line 775 of file FileBackend.php.

References clearCache(), doCreateInternal(), maxFileSizeInternal(), Status\newFatal(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

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

Parameters:
$paramsArray
Returns:
Status

Definition at line 857 of file FileBackend.php.

References clearCache(), doDeleteInternal(), wfProfileIn(), and wfProfileOut().

Referenced by doMoveInternal().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::doCleanInternal ( container,
dir,
array $  params 
) [protected]
See also:
FileBackendStore::doClean()

Reimplemented in SwiftFileBackend, and FSFileBackend.

Definition at line 1086 of file FileBackend.php.

References Status\newGood().

Referenced by doClean().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::doClearCache ( array $  paths = null) [protected]

Clears any additional stat caches for storage paths.

See also:
FileBackend::clearCache()
Parameters:
$pathsArray Storage paths (optional)
Returns:
void

Reimplemented in SwiftFileBackend, and FSFileBackend.

Definition at line 1427 of file FileBackend.php.

Referenced by clearCache().

Here is the caller graph for this function:

FileBackendStore::doConcatenate ( array $  params) [protected]
See also:
FileBackendStore::concatenate()

Definition at line 925 of file FileBackend.php.

References $ok, getLocalReference(), Status\newGood(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by concatenate().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::doCopyInternal ( array $  params) [abstract, protected]
See also:
FileBackendStore::copyInternal()

Reimplemented in SwiftFileBackend, and FSFileBackend.

Referenced by copyInternal().

Here is the caller graph for this function:

FileBackendStore::doCreateInternal ( array $  params) [abstract, protected]
See also:
FileBackendStore::createInternal()

Reimplemented in FSFileBackend, and SwiftFileBackend.

Referenced by createInternal().

Here is the caller graph for this function:

FileBackendStore::doDeleteInternal ( array $  params) [abstract, protected]
See also:
FileBackendStore::deleteInternal()

Reimplemented in SwiftFileBackend, and FSFileBackend.

Referenced by deleteInternal().

Here is the caller graph for this function:

FileBackendStore::doGetFileSha1Base36 ( array $  params) [protected]
See also:
FileBackendStore::getFileSha1Base36()

Definition at line 1192 of file FileBackend.php.

References getLocalReference().

Referenced by getFileSha1Base36().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::doGetFileStat ( array $  params) [abstract, protected]
See also:
FileBackendStore::getFileStat()

Reimplemented in SwiftFileBackend, and FSFileBackend.

Referenced by getFileStat().

Here is the caller graph for this function:

FileBackendStore::doMoveInternal ( array $  params) [protected]
See also:
FileBackendStore::moveInternal()

Reimplemented in FSFileBackend.

Definition at line 893 of file FileBackend.php.

References copyInternal(), and deleteInternal().

Referenced by moveInternal().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::doOperationsInternal ( array $  ops,
array $  opts 
) [protected]
FileBackendStore::doPrepare ( array $  params) [final, protected]
See also:
FileBackend::doPrepare()

Reimplemented from FileBackend.

Definition at line 980 of file FileBackend.php.

References $dir, doPrepareInternal(), getContainerSuffixes(), Status\newGood(), resolveStoragePath(), FileBackend\splitStoragePath(), wfDebug(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

FileBackendStore::doPrepareInternal ( container,
dir,
array $  params 
) [protected]
See also:
FileBackendStore::doPrepare()

Reimplemented in FSFileBackend, and SwiftFileBackend.

Definition at line 1008 of file FileBackend.php.

References Status\newGood().

Referenced by doPrepare().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::doSecure ( array $  params) [final, protected]
See also:
FileBackend::doSecure()

Reimplemented from FileBackend.

Definition at line 1015 of file FileBackend.php.

References $dir, doSecureInternal(), getContainerSuffixes(), Status\newGood(), resolveStoragePath(), FileBackend\splitStoragePath(), wfDebug(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

FileBackendStore::doSecureInternal ( container,
dir,
array $  params 
) [protected]
See also:
FileBackendStore::doSecure()

Reimplemented in SwiftFileBackend, and FSFileBackend.

Definition at line 1043 of file FileBackend.php.

References Status\newGood().

Referenced by doSecure().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::doStoreInternal ( array $  params) [abstract, protected]
See also:
FileBackendStore::storeInternal()

Reimplemented in SwiftFileBackend, and FSFileBackend.

Referenced by storeInternal().

Here is the caller graph for this function:

FileBackendStore::doStreamFile ( array $  params) [protected]
See also:
FileBackendStore::streamFile()

Reimplemented in SwiftFileBackend.

Definition at line 1261 of file FileBackend.php.

References getLocalReference(), and Status\newGood().

Referenced by streamFile().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::fileExists ( array $  params) [final]
See also:
FileBackend::fileExists()

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().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::fullContainerName ( container) [final, protected]

Get the full container name, including the wiki ID prefix.

Parameters:
$containerstring
Returns:
string

Definition at line 1606 of file FileBackend.php.

Referenced by resolveStoragePath().

Here is the caller graph for this function:

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.

Parameters:
$containerstring
Returns:
Array (integer levels, integer base, repeat flag) or (0, 0, false)

Definition at line 1568 of file FileBackend.php.

Referenced by getContainerShard(), and getContainerSuffixes().

Here is the caller graph for this function:

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.

Parameters:
$containerstring Container name
$relStoragePathstring Storage path relative to the container
Returns:
string|null Returns null if shard could not be determined

Definition at line 1532 of file FileBackend.php.

References getContainerHashLevels().

Referenced by resolveStoragePath().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::getContainerSuffixes ( container) [final, protected]

Get a list of full container shard suffixes for a container.

Parameters:
$containerstring
Returns:
Array

Definition at line 1588 of file FileBackend.php.

References getContainerHashLevels(), and wfBaseConvert().

Referenced by doClean(), doPrepare(), doSecure(), and getFileList().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::getFileContents ( array $  params)
See also:
FileBackend::getFileContents()

Reimplemented from FileBackend.

Reimplemented in SwiftFileBackend.

Definition at line 1156 of file FileBackend.php.

References getLocalReference(), wfProfileIn(), wfProfileOut(), wfRestoreWarnings(), and wfSuppressWarnings().

Here is the call graph for this function:

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

Returns:
Traversable|Array|null Returns null on failure

Reimplemented from FileBackend.

Definition at line 1277 of file FileBackend.php.

References $dir, getContainerSuffixes(), getFileListInternal(), resolveStoragePath(), FileBackend\splitStoragePath(), and wfDebug().

Here is the call graph for this function:

FileBackendStore::getFileListInternal ( container,
dir,
array $  params 
) [abstract]

Do not call this function from places outside FileBackend.

See also:
FileBackendStore::getFileList()
Parameters:
$containerstring Resolved container name
$dirstring Resolved path relative to container
$paramsArray
Returns:
Traversable|Array|null

Reimplemented in SwiftFileBackend, and FSFileBackend.

Referenced by getFileList().

Here is the caller graph for this function:

FileBackendStore::getFileProps ( array $  params) [final]
See also:
FileBackend::getFileProps()

Reimplemented from FileBackend.

Definition at line 1204 of file FileBackend.php.

References getLocalReference(), FSFile\placeholderProps(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

FileBackendStore::getFileSha1Base36 ( array $  params) [final]
See also:
FileBackend::getFileSha1Base36()

Reimplemented from FileBackend.

Definition at line 1173 of file FileBackend.php.

References $path, doGetFileSha1Base36(), trimCache(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

FileBackendStore::getFileSize ( array $  params) [final]
See also:
FileBackend::getFileSize()

Reimplemented from FileBackend.

Definition at line 1113 of file FileBackend.php.

References getFileStat(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

FileBackendStore::getFileStat ( array $  params) [final]
See also:
FileBackend::getFileStat()

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().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::getFileTimestamp ( array $  params) [final]
See also:
FileBackend::getFileTimestamp()

Reimplemented from FileBackend.

Definition at line 1103 of file FileBackend.php.

References getFileStat(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

See also:
FileBackend::getLocalReference()

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
$opsArray Same format as doOperations()
Returns:
Array List of FileOp objects
Exceptions:
MWException

Definition at line 1333 of file FileBackend.php.

References supportedOperations().

Referenced by doOperationsInternal().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
$storagePathstring
Returns:
bool

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.

Parameters:
$containerstring
Returns:
bool

Definition at line 1460 of file FileBackend.php.

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.

Returns:
integer Bytes

Definition at line 749 of file FileBackend.php.

Referenced by createInternal(), and storeInternal().

Here is the caller graph for this function:

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

Parameters:
$paramsArray
Returns:
Status

Definition at line 882 of file FileBackend.php.

References clearCache(), doMoveInternal(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

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.

Parameters:
$containerstring
Returns:
string|null

Definition at line 1622 of file FileBackend.php.

Referenced by resolveStoragePath().

Here is the caller graph for this function:

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).

Parameters:
$containerstring Container name
$relStoragePathstring Storage path relative to the container
Returns:
string|null Path or null if not valid

Reimplemented in SwiftFileBackend, and FSFileBackend.

Definition at line 1636 of file FileBackend.php.

Referenced by resolveStoragePath().

Here is the caller graph for this function:

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.

Parameters:
$storagePathstring
Returns:
Array (container, path, container suffix) or (null, null, null) if invalid

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().

Here is the call graph for this function:

Here is the caller graph for this function:

FileBackendStore::resolveStoragePathReal ( storagePath) [final, protected]

Like resolveStoragePath() except null values are returned if the container is sharded and the shard could not be determined.

See also:
FileBackendStore::resolveStoragePath()
Parameters:
$storagePathstring
Returns:
Array (container, path) or (null, null) if invalid

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
$paramsArray
Returns:
Status

Definition at line 804 of file FileBackend.php.

References clearCache(), doStoreInternal(), maxFileSizeInternal(), Status\newFatal(), wfProfileIn(), and wfProfileOut().

Here is the call graph for this function:

FileBackendStore::streamFile ( array $  params) [final]
See also:
FileBackend::streamFile()

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().

Here is the call graph for this function:

Get the list of supported operations and their corresponding FileOp classes.

Returns:
Array

Definition at line 1311 of file FileBackend.php.

Referenced by getOperations().

Here is the caller graph for this function:

FileBackendStore::trimCache ( ) [protected]

Prune the inexpensive cache if it is too big to add an item.

Returns:
void

Definition at line 1434 of file FileBackend.php.

Referenced by getFileSha1Base36(), and getFileStat().

Here is the caller graph for this function:

Prune the expensive cache if it is too big to add an item.

Returns:
void

Definition at line 1446 of file FileBackend.php.

Referenced by getLocalReference().

Here is the caller graph for this function:


Member Data Documentation

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.


The documentation for this class was generated from the following file: