MediaWiki  REL1_24
FSFileBackend Class Reference

Class for a file system (FS) based file backend. More...

Inheritance diagram for FSFileBackend:
Collaboration diagram for FSFileBackend:

List of all members.

Public Member Functions

 __construct (array $config)
 getDirectoryListInternal ($fullCont, $dirRel, array $params)
 getFeatures ()
 Get the a bitfield of extra features supported by the backend medium.
 getFileListInternal ($fullCont, $dirRel, array $params)
 handleWarning ($errno, $errstr)
 isPathUsableInternal ($storagePath)
 Check if a file can be created or changed at a given storage path.

Protected Member Functions

 chmod ($path)
 Chmod a file, suppressing the warnings.
 cleanPathSlashes ($path)
 Clean up directory separators for the given OS.
 containerFSRoot ($shortCont, $fullCont)
 Given the short (unresolved) and full (resolved) name of a container, return the file system path of the container.
 directoriesAreVirtual ()
 Is this a key/value store where directories are just virtual? Virtual directories exists in so much as files exists that are prefixed with the directory path followed by a forward slash.
 doCleanInternal ($fullCont, $dirRel, array $params)
 doClearCache (array $paths=null)
 doCopyInternal (array $params)
 doCreateInternal (array $params)
 doDeleteInternal (array $params)
 doDirectoryExists ($fullCont, $dirRel, array $params)
 doExecuteOpHandlesInternal (array $fileOpHandles)
 doGetFileStat (array $params)
 doGetLocalCopyMulti (array $params)
 doGetLocalReferenceMulti (array $params)
 doMoveInternal (array $params)
 doPrepareInternal ($fullCont, $dirRel, array $params)
 doPublishInternal ($fullCont, $dirRel, array $params)
 doSecureInternal ($fullCont, $dirRel, array $params)
 doStoreInternal (array $params)
 htaccessPrivate ()
 Return the text of a .htaccess file to make a directory private.
 indexHtmlPrivate ()
 Return the text of an index.html file to hide directory listings.
 isLegalRelPath ($path)
 Sanity check a relative file system path for validity.
 resolveContainerPath ($container, $relStoragePath)
 Resolve a relative storage path, checking if it's allowed by the backend.
 resolveToFSPath ($storagePath)
 Get the absolute file system path for a storage path.
 trapWarnings ()
 Listen for E_WARNING errors and track whether any happen.
 untrapWarnings ()
 Stop listening for E_WARNING errors and return true if any happened.

Protected Attributes

string $basePath
 Directory holding the container directories *.
array $containerPaths = array()
 Map of container names to root paths for custom container paths *.
string $currentUser
 OS username running this script *.
int $fileMode
 File permission mode *.
string $fileOwner
 Required OS username to own files *.
array $hadWarningErrors = array()
 *

Detailed Description

Class for a file system (FS) based file backend.

All "containers" each map to a directory under the backend's base directory. For backwards-compatibility, some container paths can be set to custom paths. The wiki ID will not be used in any custom paths, so this should be avoided.

Having directories with thousands of files will diminish performance. Sharding can be accomplished by using FileRepo-style hash paths.

Status messages should avoid mentioning the internal FS paths. PHP warnings are assumed to be logged rather than output.

Since:
1.19

Definition at line 41 of file FSFileBackend.php.


Constructor & Destructor Documentation

See also:
FileBackendStore::__construct() Additional $config params include:

Reimplemented from FileBackendStore.

Definition at line 62 of file FSFileBackend.php.


Member Function Documentation

FSFileBackend::chmod ( path) [protected]

Chmod a file, suppressing the warnings.

Parameters:
string$pathAbsolute file system path
Returns:
bool Success

Definition at line 711 of file FSFileBackend.php.

FSFileBackend::cleanPathSlashes ( path) [protected]

Clean up directory separators for the given OS.

Parameters:
string$pathFS path
Returns:
string

Definition at line 743 of file FSFileBackend.php.

FSFileBackend::containerFSRoot ( shortCont,
fullCont 
) [protected]

Given the short (unresolved) and full (resolved) name of a container, return the file system path of the container.

Parameters:
string$shortCont
string$fullCont
Returns:
string|null

Definition at line 129 of file FSFileBackend.php.

Is this a key/value store where directories are just virtual? Virtual directories exists in so much as files exists that are prefixed with the directory path followed by a forward slash.

Returns:
bool

Reimplemented from FileBackendStore.

Definition at line 671 of file FSFileBackend.php.

FSFileBackend::doCleanInternal ( container,
dir,
array params 
) [protected]
See also:
FileBackendStore::doClean()
Parameters:
string$container
string$dir
array$params
Returns:
Status

Reimplemented from FileBackendStore.

Definition at line 519 of file FSFileBackend.php.

FSFileBackend::doClearCache ( array paths = null) [protected]
See also:
FileBackendStore::doClearCache()

Reimplemented from FileBackendStore.

Definition at line 558 of file FSFileBackend.php.

FSFileBackend::doCopyInternal ( array params) [protected]
See also:
FileBackendStore::copyInternal()
Parameters:
array$params
Returns:
Status

Reimplemented from FileBackendStore.

Definition at line 276 of file FSFileBackend.php.

FSFileBackend::doCreateInternal ( array params) [protected]
See also:
FileBackendStore::createInternal()
Parameters:
array$params
Returns:
Status

Reimplemented from FileBackendStore.

Definition at line 180 of file FSFileBackend.php.

FSFileBackend::doDeleteInternal ( array params) [protected]
See also:
FileBackendStore::deleteInternal()
Parameters:
array$params
Returns:
Status

Reimplemented from FileBackendStore.

Definition at line 389 of file FSFileBackend.php.

FSFileBackend::doDirectoryExists ( container,
dir,
array params 
) [protected]
See also:
FileBackendStore::directoryExists()
Parameters:
string$containerResolved container name
string$dirResolved path relative to container
array$params
Returns:
bool|null

Reimplemented from FileBackendStore.

Definition at line 562 of file FSFileBackend.php.

FSFileBackend::doExecuteOpHandlesInternal ( array fileOpHandles) [protected]
See also:
FileBackendStore::executeOpHandlesInternal()
Parameters:
array$fileOpHandles
Exceptions:
FileBackendError
Returns:
array List of corresponding Status objects

Reimplemented from FileBackendStore.

Definition at line 675 of file FSFileBackend.php.

FSFileBackend::doGetFileStat ( array params) [protected]
See also:
FileBackendStore::getFileStat()

Reimplemented from FileBackendStore.

Definition at line 533 of file FSFileBackend.php.

FSFileBackend::doGetLocalCopyMulti ( array params) [protected]
See also:
FileBackendStore::getLocalCopyMulti()
Parameters:
array$params
Returns:
array

Reimplemented from FileBackendStore.

Definition at line 639 of file FSFileBackend.php.

See also:
FileBackendStore::getLocalReferenceMulti()
Parameters:
array$params
Returns:
array

Reimplemented from FileBackendStore.

Definition at line 624 of file FSFileBackend.php.

FSFileBackend::doMoveInternal ( array params) [protected]
See also:
FileBackendStore::moveInternal()
Parameters:
array$params
Returns:
Status

Reimplemented from FileBackendStore.

Definition at line 336 of file FSFileBackend.php.

FSFileBackend::doPrepareInternal ( fullCont,
dirRel,
array params 
) [protected]
Parameters:
string$fullCont
string$dirRel
array$params
Returns:
Status

Reimplemented from FileBackendStore.

Definition at line 439 of file FSFileBackend.php.

FSFileBackend::doPublishInternal ( container,
dir,
array params 
) [protected]
See also:
FileBackendStore::doPublish()
Parameters:
string$container
string$dir
array$params
Returns:
Status

Reimplemented from FileBackendStore.

Definition at line 491 of file FSFileBackend.php.

FSFileBackend::doSecureInternal ( container,
dir,
array params 
) [protected]
See also:
FileBackendStore::doSecure()
Parameters:
string$container
string$dir
array$params
Returns:
Status

Reimplemented from FileBackendStore.

Definition at line 463 of file FSFileBackend.php.

FSFileBackend::doStoreInternal ( array params) [protected]
See also:
FileBackendStore::storeInternal()
Parameters:
array$params
Returns:
Status

Reimplemented from FileBackendStore.

Definition at line 233 of file FSFileBackend.php.

FSFileBackend::getDirectoryListInternal ( fullCont,
dirRel,
array params 
)
See also:
FileBackendStore::getDirectoryListInternal()
Parameters:
string$fullCont
string$dirRel
array$params
Returns:
array|null

Reimplemented from FileBackendStore.

Definition at line 581 of file FSFileBackend.php.

Get the a bitfield of extra features supported by the backend medium.

Returns:
int Bitfield of FileBackend::ATTR_* flags
Since:
1.23

Reimplemented from FileBackend.

Definition at line 87 of file FSFileBackend.php.

FSFileBackend::getFileListInternal ( fullCont,
dirRel,
array params 
)
See also:
FileBackendStore::getFileListInternal()
Parameters:
string$fullCont
string$dirRel
array$params
Returns:
array|FSFileBackendFileList|null

Reimplemented from FileBackendStore.

Definition at line 606 of file FSFileBackend.php.

FSFileBackend::handleWarning ( errno,
errstr 
)
Parameters:
int$errno
string$errstr
Returns:
bool
Access:
private

Definition at line 771 of file FSFileBackend.php.

Return the text of a .htaccess file to make a directory private.

Returns:
string

Definition at line 733 of file FSFileBackend.php.

Return the text of an index.html file to hide directory listings.

Returns:
string

Definition at line 724 of file FSFileBackend.php.

FSFileBackend::isLegalRelPath ( path) [protected]

Sanity check a relative file system path for validity.

Parameters:
string$pathNormalized relative path
Returns:
bool

Definition at line 109 of file FSFileBackend.php.

Check if a file can be created or changed at a given storage path.

FS backends should check if the parent directory exists, files can be written under it, and that any file already there is writable. Backends using key/value stores should check if the container exists.

Parameters:
string$storagePath
Returns:
bool

Reimplemented from FileBackendStore.

Definition at line 159 of file FSFileBackend.php.

FSFileBackend::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:
string$containerContainer name
string$relStoragePathStorage path relative to the container
Returns:
string|null Path or null if not valid

Reimplemented from FileBackendStore.

Definition at line 91 of file FSFileBackend.php.

FSFileBackend::resolveToFSPath ( storagePath) [protected]

Get the absolute file system path for a storage path.

Parameters:
string$storagePathStorage path
Returns:
string|null

Definition at line 145 of file FSFileBackend.php.

FSFileBackend::trapWarnings ( ) [protected]

Listen for E_WARNING errors and track whether any happen.

Definition at line 750 of file FSFileBackend.php.

Stop listening for E_WARNING errors and return true if any happened.

Returns:
bool

Definition at line 760 of file FSFileBackend.php.


Member Data Documentation

string FSFileBackend::$basePath [protected]

Directory holding the container directories *.

Definition at line 42 of file FSFileBackend.php.

array FSFileBackend::$containerPaths = array() [protected]

Map of container names to root paths for custom container paths *.

Definition at line 44 of file FSFileBackend.php.

string FSFileBackend::$currentUser [protected]

OS username running this script *.

Definition at line 50 of file FSFileBackend.php.

int FSFileBackend::$fileMode [protected]

File permission mode *.

Definition at line 46 of file FSFileBackend.php.

string FSFileBackend::$fileOwner [protected]

Required OS username to own files *.

Definition at line 48 of file FSFileBackend.php.

array FSFileBackend::$hadWarningErrors = array() [protected]

*

Definition at line 52 of file FSFileBackend.php.


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