[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/filebackend/ -> FileBackend.php (summary)

(no description)

File Size: 1504 lines (55 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

FileBackendException:: (0 methods):

FileBackendError:: (0 methods):

Defines 0 functions

  __construct()
  getName()
  getWikiId()
  isReadOnly()
  getReadOnlyReason()
  getFeatures()
  hasFeatures()
  doOperations()
  doOperation()
  create()
  store()
  copy()
  move()
  delete()
  describe()
  doQuickOperations()
  doQuickOperation()
  quickCreate()
  quickStore()
  quickCopy()
  quickMove()
  quickDelete()
  quickDescribe()
  prepare()
  secure()
  publish()
  clean()
  getScopedPHPBehaviorForOps()
  getFileContents()
  getLocalReference()
  getLocalCopy()
  getTopDirectoryList()
  getTopFileList()
  lockFiles()
  unlockFiles()
  getScopedFileLocks()
  getRootStoragePath()
  getContainerStoragePath()
  getJournal()
  isStoragePath()
  splitStoragePath()
  normalizeStoragePath()
  parentStoragePath()
  extensionFromPath()
  isPathTraversalFree()
  makeContentDisposition()
  normalizeContainerPath()

Class: FileBackendException  - X-Ref

Generic file backend exception for checked and unexpected (e.g. config) exceptions

Class: FileBackendError  - X-Ref

File backend exception for checked exceptions (e.g. I/O errors)

Functions
Functions that are not part of a class:

__construct( array $config )   X-Ref
Create a new backend instance from configuration.
This should only be called from within FileBackendGroup.

param: array $config Parameters include:

getName()   X-Ref
Get the unique backend name.
We may have multiple different backends of the same type.
For example, we can have two Swift backends using different proxies.

return: string

getWikiId()   X-Ref
Get the wiki identifier used for this backend (possibly empty).
Note that this might *not* be in the same format as wfWikiID().

return: string

isReadOnly()   X-Ref
Check if this backend is read-only

return: bool

getReadOnlyReason()   X-Ref
Get an explanatory message if this backend is read-only

return: string|bool Returns false if the backend is not read-only

getFeatures()   X-Ref
Get the a bitfield of extra features supported by the backend medium

return: int Bitfield of FileBackend::ATTR_* flags

hasFeatures( $bitfield )   X-Ref
Check if the backend medium supports a field of extra features

param: int $bitfield Bitfield of FileBackend::ATTR_* flags
return: bool

doOperations( array $ops, array $opts = array()   X-Ref
This is the main entry point into the backend for write operations.
Callers supply an ordered list of operations to perform as a transaction.
Files will be locked, the stat cache cleared, and then the operations attempted.
If any serious errors occur, all attempted operations will be rolled back.

$ops is an array of arrays. The outer array holds a list of operations.
Each inner array is a set of key value pairs that specify an operation.

Supported operations and their parameters. The supported actions are:
- create
- store
- copy
- move
- delete
- describe (since 1.21)
- null

a) Create a new file in storage with the contents of a string
param: array $ops List of operations to execute in order
param: array $opts Batch operation options
return: Status

doOperation( array $op, array $opts = array()   X-Ref
Same as doOperations() except it takes a single operation.
If you are doing a batch of operations that should either
all succeed or all fail, then use that function instead.

param: array $op Operation
param: array $opts Operation options
return: Status

create( array $params, array $opts = array()   X-Ref
Performs a single create operation.
This sets $params['op'] to 'create' and passes it to doOperation().

param: array $params Operation parameters
param: array $opts Operation options
return: Status

store( array $params, array $opts = array()   X-Ref
Performs a single store operation.
This sets $params['op'] to 'store' and passes it to doOperation().

param: array $params Operation parameters
param: array $opts Operation options
return: Status

copy( array $params, array $opts = array()   X-Ref
Performs a single copy operation.
This sets $params['op'] to 'copy' and passes it to doOperation().

param: array $params Operation parameters
param: array $opts Operation options
return: Status

move( array $params, array $opts = array()   X-Ref
Performs a single move operation.
This sets $params['op'] to 'move' and passes it to doOperation().

param: array $params Operation parameters
param: array $opts Operation options
return: Status

delete( array $params, array $opts = array()   X-Ref
Performs a single delete operation.
This sets $params['op'] to 'delete' and passes it to doOperation().

param: array $params Operation parameters
param: array $opts Operation options
return: Status

describe( array $params, array $opts = array()   X-Ref
Performs a single describe operation.
This sets $params['op'] to 'describe' and passes it to doOperation().

param: array $params Operation parameters
param: array $opts Operation options
return: Status

doQuickOperations( array $ops, array $opts = array()   X-Ref
Perform a set of independent file operations on some files.

This does no locking, nor journaling, and possibly no stat calls.
Any destination files that already exist will be overwritten.
This should *only* be used on non-original files, like cache files.

Supported operations and their parameters:
- create
- store
- copy
- move
- delete
- describe (since 1.21)
- null

a) Create a new file in storage with the contents of a string
param: array $ops Set of operations to execute
param: array $opts Batch operation options
return: Status

doQuickOperation( array $op )   X-Ref
Same as doQuickOperations() except it takes a single operation.
If you are doing a batch of operations, then use that function instead.

param: array $op Operation
return: Status

quickCreate( array $params )   X-Ref
Performs a single quick create operation.
This sets $params['op'] to 'create' and passes it to doQuickOperation().

param: array $params Operation parameters
return: Status

quickStore( array $params )   X-Ref
Performs a single quick store operation.
This sets $params['op'] to 'store' and passes it to doQuickOperation().

param: array $params Operation parameters
return: Status

quickCopy( array $params )   X-Ref
Performs a single quick copy operation.
This sets $params['op'] to 'copy' and passes it to doQuickOperation().

param: array $params Operation parameters
return: Status

quickMove( array $params )   X-Ref
Performs a single quick move operation.
This sets $params['op'] to 'move' and passes it to doQuickOperation().

param: array $params Operation parameters
return: Status

quickDelete( array $params )   X-Ref
Performs a single quick delete operation.
This sets $params['op'] to 'delete' and passes it to doQuickOperation().

param: array $params Operation parameters
return: Status

quickDescribe( array $params )   X-Ref
Performs a single quick describe operation.
This sets $params['op'] to 'describe' and passes it to doQuickOperation().

param: array $params Operation parameters
return: Status

prepare( array $params )   X-Ref
Prepare a storage directory for usage.
This will create any required containers and parent directories.
Backends using key/value stores only need to create the container.

The 'noAccess' and 'noListing' parameters works the same as in secure(),
except they are only applied *if* the directory/container had to be created.
These flags should always be set for directories that have private files.
However, setting them is not guaranteed to actually do anything.
Additional server configuration may be needed to achieve the desired effect.

param: array $params Parameters include:
return: Status

secure( array $params )   X-Ref
Take measures to block web access to a storage directory and
the container it belongs to. FS backends might add .htaccess
files whereas key/value store backends might revoke container
access to the storage user representing end-users in web requests.

This is not guaranteed to actually make files or listings publically hidden.
Additional server configuration may be needed to achieve the desired effect.

param: array $params Parameters include:
return: Status

publish( array $params )   X-Ref
Remove measures to block web access to a storage directory and
the container it belongs to. FS backends might remove .htaccess
files whereas key/value store backends might grant container
access to the storage user representing end-users in web requests.
This essentially can undo the result of secure() calls.

This is not guaranteed to actually make files or listings publically viewable.
Additional server configuration may be needed to achieve the desired effect.

param: array $params Parameters include:
return: Status

clean( array $params )   X-Ref
Delete a storage directory if it is empty.
Backends using key/value stores may do nothing unless the directory
is that of an empty container, in which case it will be deleted.

param: array $params Parameters include:
return: Status

getScopedPHPBehaviorForOps()   X-Ref
Enter file operation scope.
This just makes PHP ignore user aborts/disconnects until the return
value leaves scope. This returns null and does nothing in CLI mode.

return: ScopedCallback|null

getFileContents( array $params )   X-Ref
Get the contents of a file at a storage path in the backend.
This should be avoided for potentially large files.

param: array $params Parameters include:
return: string|bool Returns false on failure

getLocalReference( array $params )   X-Ref
Returns a file system file, identical to the file at a storage path.
The file returned is either:
- a) A local copy of the file at a storage path in the backend.
The temporary copy will have the same extension as the source.
- b) An original of the file at a storage path in the backend.
Temporary files may be purged when the file object falls out of scope.

Write operations should *never* be done on this file as some backends
may do internal tracking or may be instances of FileBackendMultiWrite.
In that later case, there are copies of the file that must stay in sync.
Additionally, further calls to this function may return the same file.

param: array $params Parameters include:
return: FSFile|null Returns null on failure

getLocalCopy( array $params )   X-Ref
Get a local copy on disk of the file at a storage path in the backend.
The temporary copy will have the same file extension as the source.
Temporary files may be purged when the file object falls out of scope.

param: array $params Parameters include:
return: TempFSFile|null Returns null on failure

getTopDirectoryList( array $params )   X-Ref
Same as FileBackend::getDirectoryList() except only lists
directories that are immediately under the given directory.

Storage backends with eventual consistency might return stale data.

Failures during iteration can result in FileBackendError exceptions (since 1.22).

param: array $params Parameters include:
return: Traversable|array|null Returns null on failure

getTopFileList( array $params )   X-Ref
Same as FileBackend::getFileList() except only lists
files that are immediately under the given directory.

Storage backends with eventual consistency might return stale data.

Failures during iteration can result in FileBackendError exceptions (since 1.22).

param: array $params Parameters include:
return: Traversable|array|null Returns null on failure

lockFiles( array $paths, $type, $timeout = 0 )   X-Ref
Lock the files at the given storage paths in the backend.
This will either lock all the files or none (on failure).

Callers should consider using getScopedFileLocks() instead.

param: array $paths Storage paths
param: int $type LockManager::LOCK_* constant
param: int $timeout Timeout in seconds (0 means non-blocking) (since 1.24)
return: Status

unlockFiles( array $paths, $type )   X-Ref
Unlock the files at the given storage paths in the backend.

param: array $paths Storage paths
param: int $type LockManager::LOCK_* constant
return: Status

getScopedFileLocks( array $paths, $type, Status $status, $timeout = 0 )   X-Ref
Lock the files at the given storage paths in the backend.
This will either lock all the files or none (on failure).
On failure, the status object will be updated with errors.

Once the return value goes out scope, the locks will be released and
the status updated. Unlock fatals will not change the status "OK" value.

param: array $paths List of storage paths or map of lock types to path lists
param: int|string $type LockManager::LOCK_* constant or "mixed"
param: Status $status Status to update on lock/unlock
param: int $timeout Timeout in seconds (0 means non-blocking) (since 1.24)
return: ScopedLock|null Returns null on failure

getRootStoragePath()   X-Ref
Get the root storage path of this backend.
All container paths are "subdirectories" of this path.

return: string Storage path

getContainerStoragePath( $container )   X-Ref
Get the storage path for the given container for this backend

param: string $container Container name
return: string Storage path

getJournal()   X-Ref
Get the file journal object for this backend

return: FileJournal

isStoragePath( $path )   X-Ref
Check if a given path is a "mwstore://" path.
This does not do any further validation or any existence checks.

param: string $path
return: bool

splitStoragePath( $storagePath )   X-Ref
Split a storage path into a backend name, a container name,
and a relative file path. The relative path may be the empty string.
This does not do any path normalization or traversal checks.

param: string $storagePath
return: array (backend, container, rel object) or (null, null, null)

normalizeStoragePath( $storagePath )   X-Ref
Normalize a storage path by cleaning up directory separators.
Returns null if the path is not of the format of a valid storage path.

param: string $storagePath
return: string|null

parentStoragePath( $storagePath )   X-Ref
Get the parent storage directory of a storage path.
This returns a path like "mwstore://backend/container",
"mwstore://backend/container/...", or null if there is no parent.

param: string $storagePath
return: string|null

extensionFromPath( $path, $case = 'lowercase' )   X-Ref
Get the final extension from a storage or FS path

param: string $path
param: string $case One of (rawcase, uppercase, lowercase) (since 1.24)
return: string

isPathTraversalFree( $path )   X-Ref
Check if a relative path has no directory traversals

param: string $path
return: bool

makeContentDisposition( $type, $filename = '' )   X-Ref
Build a Content-Disposition header value per RFC 6266.

param: string $type One of (attachment, inline)
param: string $filename Suggested file name (should not contain slashes)
return: string

normalizeContainerPath( $path )   X-Ref
Validate and normalize a relative storage path.
Null is returned if the path involves directory traversal.
Traversal is insecure for FS backends and broken for others.

This uses the same traversal protection as Title::secureAndSplit().

param: string $path Storage path relative to a container
return: string|null



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1