MediaWiki
1.32.0
|
Base class for all file backend classes (including multi-write backends). More...
Public Member Functions | |
__construct (array $config) | |
Create a new backend instance from configuration. More... | |
clean (array $params) | |
Delete a storage directory if it is empty. More... | |
clearCache (array $paths=null) | |
Invalidate any in-process file stat and property cache. More... | |
concatenate (array $params) | |
Concatenate a list of storage files into a single file system file. More... | |
copy (array $params, array $opts=[]) | |
Performs a single copy operation. More... | |
create (array $params, array $opts=[]) | |
Performs a single create operation. More... | |
delete (array $params, array $opts=[]) | |
Performs a single delete operation. More... | |
describe (array $params, array $opts=[]) | |
Performs a single describe operation. More... | |
directoryExists (array $params) | |
Check if a directory exists at a given storage path. More... | |
doOperation (array $op, array $opts=[]) | |
Same as doOperations() except it takes a single operation. More... | |
doOperations (array $ops, array $opts=[]) | |
This is the main entry point into the backend for write operations. More... | |
doQuickOperation (array $op) | |
Same as doQuickOperations() except it takes a single operation. More... | |
doQuickOperations (array $ops, array $opts=[]) | |
Perform a set of independent file operations on some files. More... | |
fileExists (array $params) | |
Check if a file exists at a storage path in the backend. More... | |
getContainerStoragePath ( $container) | |
Get the storage path for the given container for this backend. More... | |
getDirectoryList (array $params) | |
Get an iterator to list all directories under a storage directory. More... | |
getDomainId () | |
Get the domain identifier used for this backend (possibly empty). More... | |
getFeatures () | |
Get the a bitfield of extra features supported by the backend medium. More... | |
getFileContents (array $params) | |
Get the contents of a file at a storage path in the backend. More... | |
getFileContentsMulti (array $params) | |
Like getFileContents() except it takes an array of storage paths and returns a map of storage paths to strings (or null on failure). More... | |
getFileHttpUrl (array $params) | |
Return an HTTP URL to a given file that requires no authentication to use. More... | |
getFileList (array $params) | |
Get an iterator to list all stored files under a storage directory. More... | |
getFileProps (array $params) | |
Get the properties of the file at a storage path in the backend. More... | |
getFileSha1Base36 (array $params) | |
Get a SHA-1 hash of the file at a storage path in the backend. More... | |
getFileSize (array $params) | |
Get the size (bytes) of a file at a storage path in the backend. More... | |
getFileStat (array $params) | |
Get quick information about a file at a storage path in the backend. More... | |
getFileTimestamp (array $params) | |
Get the last-modified timestamp of the file at a storage path. More... | |
getFileXAttributes (array $params) | |
Get metadata about a file at a storage path in the backend. More... | |
getJournal () | |
Get the file journal object for this backend. More... | |
getLocalCopy (array $params) | |
Get a local copy on disk of the file at a storage path in the backend. More... | |
getLocalCopyMulti (array $params) | |
Like getLocalCopy() except it takes an array of storage paths and returns a map of storage paths to TempFSFile objects (or null on failure). More... | |
getLocalReference (array $params) | |
Returns a file system file, identical to the file at a storage path. More... | |
getLocalReferenceMulti (array $params) | |
Like getLocalReference() except it takes an array of storage paths and returns a map of storage paths to FSFile objects (or null on failure). More... | |
getName () | |
Get the unique backend name. More... | |
getReadOnlyReason () | |
Get an explanatory message if this backend is read-only. More... | |
getRootStoragePath () | |
Get the root storage path of this backend. More... | |
getScopedFileLocks (array $paths, $type, StatusValue $status, $timeout=0) | |
Lock the files at the given storage paths in the backend. More... | |
getScopedLocksForOps (array $ops, StatusValue $status) | |
Get an array of scoped locks needed for a batch of file operations. More... | |
getTopDirectoryList (array $params) | |
Same as FileBackend::getDirectoryList() except only lists directories that are immediately under the given directory. More... | |
getTopFileList (array $params) | |
Same as FileBackend::getFileList() except only lists files that are immediately under the given directory. More... | |
getWikiId () | |
Alias to getDomainId() More... | |
hasFeatures ( $bitfield) | |
Check if the backend medium supports a field of extra features. More... | |
isReadOnly () | |
Check if this backend is read-only. More... | |
lockFiles (array $paths, $type, $timeout=0) | |
Lock the files at the given storage paths in the backend. More... | |
move (array $params, array $opts=[]) | |
Performs a single move operation. More... | |
preloadCache (array $paths) | |
Preload persistent file stat cache and property cache into in-process cache. More... | |
preloadFileStat (array $params) | |
Preload file stat information (concurrently if possible) into in-process cache. More... | |
prepare (array $params) | |
Prepare a storage directory for usage. More... | |
publish (array $params) | |
Remove measures to block web access to a storage directory and the container it belongs to. More... | |
quickCopy (array $params) | |
Performs a single quick copy operation. More... | |
quickCreate (array $params) | |
Performs a single quick create operation. More... | |
quickDelete (array $params) | |
Performs a single quick delete operation. More... | |
quickDescribe (array $params) | |
Performs a single quick describe operation. More... | |
quickMove (array $params) | |
Performs a single quick move operation. More... | |
quickStore (array $params) | |
Performs a single quick store operation. More... | |
secure (array $params) | |
Take measures to block web access to a storage directory and the container it belongs to. More... | |
setLogger (LoggerInterface $logger) | |
store (array $params, array $opts=[]) | |
Performs a single store operation. More... | |
streamFile (array $params) | |
Stream the file at a storage path in the backend. More... | |
unlockFiles (array $paths, $type) | |
Unlock the files at the given storage paths in the backend. More... | |
Static Public Member Functions | |
static | extensionFromPath ( $path, $case='lowercase') |
Get the final extension from a storage or FS path. More... | |
static | isPathTraversalFree ( $path) |
Check if a relative path has no directory traversals. More... | |
static | isStoragePath ( $path) |
Check if a given path is a "mwstore://" path. More... | |
static | makeContentDisposition ( $type, $filename='') |
Build a Content-Disposition header value per RFC 6266. More... | |
static | normalizeStoragePath ( $storagePath) |
Normalize a storage path by cleaning up directory separators. More... | |
static | parentStoragePath ( $storagePath) |
Get the parent storage directory of a storage path. More... | |
static | splitStoragePath ( $storagePath) |
Split a storage path into a backend name, a container name, and a relative file path. More... | |
Public Attributes | |
const | ATTR_HEADERS = 1 |
Bitfield flags for supported features. More... | |
const | ATTR_METADATA = 2 |
const | ATTR_UNICODE_PATHS = 4 |
Protected Member Functions | |
doClean (array $params) | |
doOperationsInternal (array $ops, array $opts) | |
doPrepare (array $params) | |
doPublish (array $params) | |
doQuickOperationsInternal (array $ops) | |
doSecure (array $params) | |
getScopedPHPBehaviorForOps () | |
Enter file operation scope. More... | |
newStatus () | |
Yields the result of the status wrapper callback on either: More... | |
resetOutputBuffer () | |
resolveFSFileObjects (array $ops) | |
Convert FSFile 'src' paths to string paths (with an 'srcRef' field set to the FSFile) More... | |
scopedProfileSection ( $section) | |
wrapStatus (StatusValue $sv) | |
Static Protected Member Functions | |
static | normalizeContainerPath ( $path) |
Validate and normalize a relative storage path. More... | |
Protected Attributes | |
int | $concurrency |
How many operations can be done in parallel. More... | |
string | $domainId |
Unique domain name. More... | |
FileJournal | $fileJournal |
LockManager | $lockManager |
LoggerInterface | $logger |
string | $name |
Unique backend name. More... | |
callable | $obResetFunc |
string | $parallelize |
When to do operations in parallel. More... | |
object string | $profiler |
Class name or object With profileIn/profileOut methods. More... | |
string | $readOnly |
Read-only explanation message. More... | |
callable | $statusWrapper |
callable | $streamMimeFunc |
string | $tmpDirectory |
Temporary file directory. More... | |
Base class for all file backend classes (including multi-write backends).
This class defines the methods as abstract that subclasses must implement. Outside callers can assume that all backends will have these functions.
All "storage paths" are of the format "mwstore://<backend>/<container>/<path>". The "backend" portion is unique name for the application to refer to a backend, while the "container" portion is a top-level directory of the backend. The "path" portion is a relative path that uses UNIX file system (FS) notation, though any particular backend may not actually be using a local filesystem. Therefore, the relative paths are only virtual.
Backend contents are stored under "domain"-specific container names by default. A domain is simply a logical umbrella for entities, such as those belonging to a certain application or portion of a website, for example. A domain can be local or global. Global (qualified) backends are achieved by configuring the "domain ID" to a constant. Global domains are simpler, but local domains can be used by choosing a domain ID based on the current context, such as which language of a website is being used.
For legacy reasons, the FSFileBackend class allows manually setting the paths of containers to ones that do not respect the "domain ID".
In key/value (object) stores, containers are the only hierarchy (the rest is emulated). FS-based backends are somewhat more restrictive due to the existence of real directory files; a regular file cannot have the same name as a directory. Other backends with virtual directories may not have this limitation. Callers should store files in such a way that no files and directories are under the same path.
In general, this class allows for callers to access storage through the same interface, without regard to the underlying storage system. However, calling code must follow certain patterns and be aware of certain things to ensure compatibility:
Methods of subclasses should avoid throwing exceptions at all costs. As a corollary, external dependencies should be kept to a minimum.
Definition at line 92 of file FileBackend.php.
FileBackend::__construct | ( | array | $config | ) |
Create a new backend instance from configuration.
This should only be called from within FileBackendGroup.
array | $config | Parameters include:
|
InvalidArgumentException |
Reimplemented in SwiftFileBackend, FileBackendMultiWrite, FSFileBackend, FileBackendStore, and FileBackendDBRepoWrapper.
Definition at line 162 of file FileBackend.php.
References class, FileJournal\factory(), name, and string.
|
final |
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.
array | $params | Parameters include:
|
Definition at line 900 of file FileBackend.php.
References $params, doClean(), getScopedPHPBehaviorForOps(), isReadOnly(), name, and newStatus().
|
abstract |
Invalidate any in-process file stat and property cache.
If $paths is given, then only the cache for those files will be cleared.
array | null | $paths | Storage paths (optional) |
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by CopyFileBackend\copyFileBatch().
|
abstract |
Concatenate a list of storage files into a single file system file.
The target path should refer to a file that is already locked or otherwise safe from modification from other processes. Normally, the file will be a new temp file, which should be adequate.
array | $params | Operation parameters, include:
|
Reimplemented in FileBackendMultiWrite, FileBackendStore, and FileBackendDBRepoWrapper.
Performs a single copy operation.
This sets $params['op'] to 'copy' and passes it to doOperation().
array | $params | Operation parameters |
array | $opts | Operation options |
Definition at line 495 of file FileBackend.php.
References doOperation().
Referenced by FSFileBackend\doCopyInternal(), FSFileBackend\doGetLocalCopyMulti(), and FSFileBackend\doStoreInternal().
Performs a single create operation.
This sets $params['op'] to 'create' and passes it to doOperation().
array | $params | Operation parameters |
array | $opts | Operation options |
Definition at line 467 of file FileBackend.php.
References doOperation().
Performs a single delete operation.
This sets $params['op'] to 'delete' and passes it to doOperation().
array | $params | Operation parameters |
array | $opts | Operation options |
Definition at line 523 of file FileBackend.php.
References doOperation().
Performs a single describe operation.
This sets $params['op'] to 'describe' and passes it to doOperation().
array | $params | Operation parameters |
array | $opts | Operation options |
Definition at line 538 of file FileBackend.php.
References doOperation().
|
abstract |
Check if a directory exists at a given storage path.
Backends using key/value stores will check if the path is a virtual directory, meaning there are files under the given directory.
Storage backends with eventual consistency might return stale data.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
|
abstractprotected |
array | $params |
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by clean().
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.
array | $op | Operation |
array | $opts | Operation options |
Definition at line 453 of file FileBackend.php.
References doOperations().
Referenced by LocalRepo\cleanupDeletedBatch(), copy(), create(), delete(), describe(), move(), and store().
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:
FSFile/TempFSFile object support was added in 1.27.
a) Create a new file in storage with the contents of a string
b) Copy a file system file into storage
c) Copy a file within storage
d) Move a file within storage
e) Delete a file within storage
f) Update metadata for a file within storage
g) Do nothing (no-op)
Boolean flags for operations (operation-specific):
$opts is an associative of boolean flags, including:
This returns a Status, which contains all warnings and fatals that occurred during the operation. The 'failCount', 'successCount', and 'success' members will reflect each operation attempted.
The StatusValue will be "OK" unless:
array | $ops | List of operations to execute in order |
array | $opts | Batch operation options |
Definition at line 416 of file FileBackend.php.
References captcha-old\count, doOperationsInternal(), getScopedPHPBehaviorForOps(), isReadOnly(), name, newStatus(), and resolveFSFileObjects().
Referenced by FileRepo\deleteBatch(), doOperation(), FileRepo\publishBatch(), MigrateFileRepoLayout\runBatch(), and FileRepo\storeBatch().
array | $ops | |
array | $opts |
Reimplemented in FileBackendStore, FileBackendDBRepoWrapper, and FileBackendMultiWrite.
Referenced by doOperations().
|
abstractprotected |
array | $params |
Reimplemented in FileBackendMultiWrite, FileBackendStore, and FileBackendDBRepoWrapper.
Referenced by prepare().
|
abstractprotected |
array | $params |
Reimplemented in FileBackendMultiWrite, FileBackendStore, and FileBackendDBRepoWrapper.
Referenced by publish().
|
final |
Same as doQuickOperations() except it takes a single operation.
If you are doing a batch of operations, then use that function instead.
array | $op | Operation |
Definition at line 690 of file FileBackend.php.
References doQuickOperations().
Referenced by quickCopy(), quickCreate(), quickDelete(), quickDescribe(), quickMove(), and quickStore().
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:
FSFile/TempFSFile object support was added in 1.27.
a) Create a new file in storage with the contents of a string
b) Copy a file system file into storage
c) Copy a file within storage
d) Move a file within storage
e) Delete a file within storage
f) Update metadata for a file within storage
g) Do nothing (no-op)
$opts is an associative of boolean flags, including:
array | $ops | Set of operations to execute |
array | $opts | Batch operation options |
Definition at line 654 of file FileBackend.php.
References as, captcha-old\count, doQuickOperationsInternal(), getScopedPHPBehaviorForOps(), isReadOnly(), name, newStatus(), and resolveFSFileObjects().
Referenced by CopyFileBackend\copyFileBatch(), CopyFileBackend\delFileBatch(), doQuickOperation(), and SyncFileBackend\syncFileBatch().
|
abstractprotected |
array | $ops |
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by doQuickOperations().
|
abstractprotected |
array | $params |
Reimplemented in FileBackendMultiWrite, FileBackendStore, and FileBackendDBRepoWrapper.
Referenced by secure().
|
staticfinal |
Get the final extension from a storage or FS path.
string | $path | |
string | $case | One of (rawcase, uppercase, lowercase) (since 1.24) |
Definition at line 1499 of file FileBackend.php.
Referenced by UploadFromChunks\concatenateChunks(), MemoryFileBackend\doGetLocalCopyMulti(), FSFileBackend\doGetLocalCopyMulti(), SwiftFileBackend\doGetLocalCopyMulti(), MediaTransformOutput\getExtension(), MWFileProps\getPropsFromPath(), File\getThumbDisposition(), FileBackendGroup\guessMimeInternal(), File\makeTransformTmpFile(), FileRepo\nameForThumb(), and FileBackendTest\testExtensionFromPath().
|
abstract |
Check if a file exists at a storage path in the backend.
This returns false if only a directory exists at the path.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by CopyFileBackend\copyFileBatch(), ForeignAPIRepo\getThumbUrlFromCache(), and SyncFileBackend\syncFileBatch().
|
final |
Get the storage path for the given container for this backend.
string | $container | Container name |
Definition at line 1386 of file FileBackend.php.
References getRootStoragePath().
|
abstract |
Get an iterator to list all directories under a storage directory.
If the directory is of the form "mwstore://backend/container", then all directories in the container will be listed. If the directory is of form "mwstore://backend/container/dir", then all directories directly under that directory will be listed. Results will be storage directories relative to the given directory.
Storage backends with eventual consistency might return stale data.
Failures during iteration can result in FileBackendError exceptions (since 1.22).
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by getTopDirectoryList().
|
final |
Get the domain identifier used for this backend (possibly empty).
Definition at line 216 of file FileBackend.php.
References $domainId.
Referenced by getWikiId().
FileBackend::getFeatures | ( | ) |
Get the a bitfield of extra features supported by the backend medium.
Reimplemented in FileBackendMultiWrite, FileBackendDBRepoWrapper, SwiftFileBackend, FSFileBackend, and MemoryFileBackend.
Definition at line 253 of file FileBackend.php.
References ATTR_UNICODE_PATHS.
Referenced by hasFeatures().
|
final |
Get the contents of a file at a storage path in the backend.
This should be avoided for potentially large files.
array | $params | Parameters include:
|
Definition at line 963 of file FileBackend.php.
References $params, and getFileContentsMulti().
|
abstract |
Like getFileContents() except it takes an array of storage paths and returns a map of storage paths to strings (or null on failure).
The map keys (paths) are in the same order as the provided list of paths.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by getFileContents().
|
abstract |
Return an HTTP URL to a given file that requires no authentication to use.
The URL may be pre-authenticated (via some token in the URL) and temporary. This will return null if the backend cannot make an HTTP URL for the file.
This is useful for key/value stores when using scripts that seek around large files and those scripts (and the backend) support HTTP Range headers. Otherwise, one would need to use getLocalReference(), which involves loading the entire file on to local disk.
array | $params | Parameters include:
|
Reimplemented in SwiftFileBackend, FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
|
abstract |
Get an iterator to list all stored files under a storage directory.
If the directory is of the form "mwstore://backend/container", then all files in the container will be listed. If the directory is of form "mwstore://backend/container/dir", then all files under that directory will be listed. Results will be storage paths relative to the given directory.
Storage backends with eventual consistency might return stale data.
Failures during iteration can result in FileBackendError exceptions (since 1.22).
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by CopyFileBackend\getListingDiffRel(), and getTopFileList().
|
abstract |
Get the properties of the file at a storage path in the backend.
This gives the result of FSFile::getProps() on a local copy of the file.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
|
abstract |
Get a SHA-1 hash of the file at a storage path in the backend.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by SyncFileBackend\filesAreSame(), and CopyFileBackend\filesAreSame().
|
abstract |
Get the size (bytes) of a file at a storage path in the backend.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by SyncFileBackend\filesAreSame().
|
abstract |
Get quick information about a file at a storage path in the backend.
If the file does not exist, then this returns false. Otherwise, the result is an associative array that includes:
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by CopyFileBackend\filesAreSame().
|
abstract |
Get the last-modified timestamp of the file at a storage path.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by ForeignAPIRepo\getThumbUrlFromCache().
|
abstract |
Get metadata about a file at a storage path in the backend.
If the file does not exist, then this returns false. Otherwise, the result is an associative array that includes:
Use FileBackend::hasFeatures() to check how well this is supported.
array | $params | $params include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
|
final |
Get the file journal object for this backend.
Definition at line 1395 of file FileBackend.php.
References $fileJournal.
Referenced by SyncFileBackend\syncBackends().
|
final |
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.
array | $params | Parameters include:
|
Definition at line 1124 of file FileBackend.php.
References $params, and getLocalCopyMulti().
Referenced by SwiftFileBackend\addMissingMetadata().
|
abstract |
Like getLocalCopy() except it takes an array of storage paths and returns a map of storage paths to TempFSFile objects (or null on failure).
The map keys (paths) are in the same order as the provided list of paths.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by getLocalCopy().
|
final |
Returns a file system file, identical to the file at a storage path.
The file returned is either:
Write operations should never be done on this file as some backends may do internal tracking or may be instances of FileBackendMultiWrite. In that latter case, there are copies of the file that must stay in sync. Additionally, further calls to this function may return the same file.
array | $params | Parameters include:
|
Definition at line 1091 of file FileBackend.php.
References $params, and getLocalReferenceMulti().
Referenced by CopyFileBackend\copyFileBatch(), FileBackendStore\doConcatenate(), FileBackendStore\doGetFileSha1Base36(), FileBackendStore\doStreamFile(), FileBackendStore\getFileProps(), and SyncFileBackend\syncFileBatch().
|
abstract |
Like getLocalReference() except it takes an array of storage paths and returns a map of storage paths to FSFile objects (or null on failure).
The map keys (paths) are in the same order as the provided list of paths.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by CopyFileBackend\copyFileBatch(), and getLocalReference().
|
final |
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.
Definition at line 206 of file FileBackend.php.
References $name.
Referenced by FileBackendDBRepoWrapper\__construct(), FileOpPerfTest\doPerfTest(), FileBackendStore\executeOpHandlesInternal(), SyncFileBackend\replaceNamePaths(), and SyncFileBackend\syncFileBatch().
|
final |
Get an explanatory message if this backend is read-only.
Definition at line 243 of file FileBackend.php.
|
final |
Get the root storage path of this backend.
All container paths are "subdirectories" of this path.
Definition at line 1375 of file FileBackend.php.
Referenced by CopyFileBackend\copyFileBatch(), CopyFileBackend\delFileBatch(), getContainerStoragePath(), and CopyFileBackend\getListingDiffRel().
|
final |
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 StatusValue object will be updated with errors.
Once the return value goes out scope, the locks will be released and the StatusValue updated. Unlock fatals will not change the StatusValue "OK" value.
array | $paths | List of storage paths or map of lock types to path lists |
int | string | $type | LockManager::LOCK_* constant or "mixed" |
StatusValue | $status | StatusValue to update on lock/unlock |
int | $timeout | Timeout in seconds (0 means non-blocking) (since 1.24) |
Definition at line 1336 of file FileBackend.php.
References $type, as, and ScopedLock\factory().
Referenced by SwiftFileBackend\addMissingMetadata(), FileBackendStore\concatenate(), FileBackendStore\doClean(), FileBackendStore\doOperationsInternal(), FileBackendMultiWrite\getScopedLocksForOps(), FileBackendStore\getScopedLocksForOps(), and SyncFileBackend\syncFileBatch().
|
abstract |
Get an array of scoped locks needed for a batch of file operations.
Normally, FileBackend::doOperations() handles locking, unless the 'nonLocking' param is passed in. This function is useful if you want the files to be locked for a broader scope than just when the files are changing. For example, if you need to update DB metadata, you may want to keep the files locked until finished.
array | $ops | List of file operations to FileBackend::doOperations() |
StatusValue | $status | StatusValue to update on lock/unlock |
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
|
finalprotected |
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.
Definition at line 922 of file FileBackend.php.
References use.
Referenced by clean(), doOperations(), doQuickOperations(), prepare(), publish(), and secure().
|
final |
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).
array | $params | Parameters include:
|
Definition at line 1212 of file FileBackend.php.
References getDirectoryList().
Referenced by FileBackendStore\doClean().
|
final |
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).
array | $params | Parameters include:
|
Definition at line 1250 of file FileBackend.php.
References getFileList().
|
final |
Alias to getDomainId()
Definition at line 225 of file FileBackend.php.
References getDomainId().
Referenced by FileBackendDBRepoWrapper\__construct(), CopyFileBackend\copyFileBatch(), and CopyFileBackend\delFileBatch().
|
final |
Check if the backend medium supports a field of extra features.
int | $bitfield | Bitfield of FileBackend::ATTR_* flags |
Definition at line 264 of file FileBackend.php.
References getFeatures().
|
staticfinal |
Check if a relative path has no directory traversals.
string | $path |
Definition at line 1519 of file FileBackend.php.
References $path.
Referenced by FileRepo\validateFilename().
|
final |
Check if this backend is read-only.
Definition at line 234 of file FileBackend.php.
Referenced by clean(), doOperations(), doQuickOperations(), prepare(), publish(), and secure().
|
staticfinal |
Check if a given path is a "mwstore://" path.
This does not do any further validation or any existence checks.
string | $path |
Definition at line 1428 of file FileBackend.php.
References $path.
Referenced by ForeignAPIRepo\fileExistsBatch(), MediaTransformOutput\getLocalCopyPath(), FileOp\normalizeIfValidStoragePath(), FileRepo\publishBatch(), FileRepo\quickImportBatch(), FileRepo\storeBatch(), StreamFile\stream(), MediaTransformOutput\streamFileWithStatus(), FileBackendTest\testIsStoragePath(), LocalFile\upload(), and wfMkdirParents().
|
final |
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.
array | $paths | Storage paths |
int | $type | LockManager::LOCK_* constant |
int | $timeout | Timeout in seconds (0 means non-blocking) (since 1.24) |
Definition at line 1301 of file FileBackend.php.
References $type, and wrapStatus().
|
staticfinal |
Build a Content-Disposition header value per RFC 6266.
string | $type | One of (attachment, inline) |
string | $filename | Suggested file name (should not contain slashes) |
FileBackendError |
Definition at line 1532 of file FileBackend.php.
References $type.
Referenced by File\getThumbDisposition(), ResourceLoaderImage\sendResponseHeaders(), and FileBackendTest\testSanitizeOpHeaders().
Performs a single move operation.
This sets $params['op'] to 'move' and passes it to doOperation().
array | $params | Operation parameters |
array | $opts | Operation options |
Definition at line 509 of file FileBackend.php.
References doOperation().
|
finalprotected |
Yields the result of the status wrapper callback on either:
string | $args,... |
Definition at line 1590 of file FileBackend.php.
References $args, captcha-old\count, StatusValue\newFatal(), StatusValue\newGood(), and wrapStatus().
Referenced by FileBackendMultiWrite\accessibilityCheck(), SwiftFileBackend\addMissingMetadata(), clean(), FileBackendStore\concatenate(), FileBackendMultiWrite\concatenate(), FileBackendMultiWrite\consistencyCheck(), SwiftFileBackend\createContainer(), FileBackendStore\createInternal(), SwiftFileBackend\deleteContainer(), FileBackendStore\describeInternal(), FileBackendStore\doClean(), FSFileBackend\doCleanInternal(), FileBackendStore\doCleanInternal(), SwiftFileBackend\doCleanInternal(), FileBackendStore\doConcatenate(), MemoryFileBackend\doCopyInternal(), FSFileBackend\doCopyInternal(), SwiftFileBackend\doCopyInternal(), MemoryFileBackend\doCreateInternal(), FSFileBackend\doCreateInternal(), SwiftFileBackend\doCreateInternal(), MemoryFileBackend\doDeleteInternal(), FSFileBackend\doDeleteInternal(), SwiftFileBackend\doDeleteInternal(), FileBackendStore\doDescribeInternal(), SwiftFileBackend\doDescribeInternal(), FileBackendMultiWrite\doDirectoryOp(), FSFileBackend\doExecuteOpHandlesInternal(), SwiftFileBackend\doExecuteOpHandlesInternal(), FSFileBackend\doMoveInternal(), SwiftFileBackend\doMoveInternal(), doOperations(), FileBackendMultiWrite\doOperationsInternal(), FileBackendStore\doOperationsInternal(), FileBackendStore\doPrepare(), FSFileBackend\doPrepareInternal(), FileBackendStore\doPrepareInternal(), SwiftFileBackend\doPrepareInternal(), FileBackendStore\doPublish(), FSFileBackend\doPublishInternal(), FileBackendStore\doPublishInternal(), SwiftFileBackend\doPublishInternal(), doQuickOperations(), FileBackendMultiWrite\doQuickOperationsInternal(), FileBackendStore\doQuickOperationsInternal(), FileBackendStore\doSecure(), FSFileBackend\doSecureInternal(), FileBackendStore\doSecureInternal(), SwiftFileBackend\doSecureInternal(), MemoryFileBackend\doStoreInternal(), FSFileBackend\doStoreInternal(), SwiftFileBackend\doStoreInternal(), FileBackendStore\doStreamFile(), SwiftFileBackend\doStreamFile(), FileBackendStore\nullInternal(), SwiftFileBackend\objectListing(), prepare(), publish(), FileBackendMultiWrite\resyncFiles(), secure(), SwiftFileBackend\setContainerAccess(), FileBackendStore\storeInternal(), and FileBackendStore\streamFile().
|
staticfinalprotected |
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().
string | $path | Storage path relative to a container |
Definition at line 1558 of file FileBackend.php.
References $path.
Referenced by normalizeStoragePath(), and FileBackendStore\resolveStoragePath().
|
staticfinal |
Normalize a storage path by cleaning up directory separators.
Returns null if the path is not of the format of a valid storage path.
string | $storagePath |
Definition at line 1463 of file FileBackend.php.
References list, normalizeContainerPath(), and splitStoragePath().
Referenced by FileBackendStore\deleteFileCache(), FileBackendStore\doMoveInternal(), FileBackendStore\getFileSha1Base36(), FileBackendStore\getFileStat(), FileBackendStore\getFileXAttributes(), FileBackendStore\getLocalReferenceMulti(), FileOp\normalizeIfValidStoragePath(), FileBackendStore\preloadFileStat(), FileBackendStore\primeFileCache(), FileBackendStore\setFileCache(), and FileBackendTest\testNormalizeStoragePath().
|
staticfinal |
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.
string | $storagePath |
Definition at line 1485 of file FileBackend.php.
References list, and splitStoragePath().
Referenced by FileBackendTest\testParentStoragePath().
|
abstract |
Preload persistent file stat cache and property cache into in-process cache.
This should be used when stat calls will be made on a known list of a many files.
array | $paths | Storage paths |
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
|
abstract |
Preload file stat information (concurrently if possible) into in-process cache.
This should be used when stat calls will be made on a known list of a many files. This does not make use of the persistent file stat cache.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
Referenced by SyncFileBackend\syncFileBatch().
|
final |
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.
array | $params | Parameters include:
|
Definition at line 810 of file FileBackend.php.
References $params, doPrepare(), getScopedPHPBehaviorForOps(), isReadOnly(), name, and newStatus().
Referenced by CopyFileBackend\copyFileBatch(), FileOpPerfTest\doPerfTest(), ForeignAPIRepo\getThumbUrlFromCache(), and SyncFileBackend\syncFileBatch().
|
final |
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.
array | $params | Parameters include:
|
Definition at line 874 of file FileBackend.php.
References $params, doPublish(), getScopedPHPBehaviorForOps(), isReadOnly(), name, and newStatus().
|
final |
Performs a single quick copy operation.
This sets $params['op'] to 'copy' and passes it to doQuickOperation().
array | $params | Operation parameters |
Definition at line 732 of file FileBackend.php.
References doQuickOperation().
|
final |
Performs a single quick create operation.
This sets $params['op'] to 'create' and passes it to doQuickOperation().
array | $params | Operation parameters |
Definition at line 704 of file FileBackend.php.
References doQuickOperation().
Referenced by ForeignAPIRepo\getThumbUrlFromCache().
|
final |
Performs a single quick delete operation.
This sets $params['op'] to 'delete' and passes it to doQuickOperation().
array | $params | Operation parameters |
Definition at line 760 of file FileBackend.php.
References doQuickOperation().
|
final |
Performs a single quick describe operation.
This sets $params['op'] to 'describe' and passes it to doQuickOperation().
array | $params | Operation parameters |
Definition at line 774 of file FileBackend.php.
References doQuickOperation().
|
final |
Performs a single quick move operation.
This sets $params['op'] to 'move' and passes it to doQuickOperation().
array | $params | Operation parameters |
Definition at line 746 of file FileBackend.php.
References doQuickOperation().
|
final |
Performs a single quick store operation.
This sets $params['op'] to 'store' and passes it to doQuickOperation().
array | $params | Operation parameters |
Definition at line 718 of file FileBackend.php.
References doQuickOperation().
|
protected |
Definition at line 1622 of file FileBackend.php.
|
protected |
Convert FSFile 'src' paths to string paths (with an 'srcRef' field set to the FSFile)
The 'srcRef' field keeps any TempFSFile objects in scope for the backend to have it around as long it needs (which may vary greatly depending on configuration)
array | $ops | File operation batch for FileBaclend::doOperations() |
Definition at line 1408 of file FileBackend.php.
References as.
Referenced by doOperations(), and doQuickOperations().
|
protected |
string | $section |
Definition at line 1613 of file FileBackend.php.
References $section.
Referenced by SwiftFileBackend\addMissingMetadata(), FileBackendStore\concatenate(), FileBackendStore\copyInternal(), FileBackendStore\createInternal(), FileBackendStore\deleteInternal(), FileBackendStore\describeInternal(), FileBackendStore\doClean(), FileBackendStore\doOperationsInternal(), FileBackendStore\doPrepare(), FileBackendStore\doPublish(), FileBackendStore\doQuickOperationsInternal(), FileBackendStore\doSecure(), FileBackendStore\executeOpHandlesInternal(), FileBackendStore\fileExists(), SwiftFileBackend\getContainerStat(), SwiftFileBackend\getDirListPageInternal(), FileBackendStore\getFileContentsMulti(), SwiftFileBackend\getFileListPageInternal(), FileBackendStore\getFileProps(), FileBackendStore\getFileSha1Base36(), FileBackendStore\getFileSize(), FileBackendStore\getFileStat(), FileBackendStore\getFileTimestamp(), FileBackendStore\getFileXAttributes(), FileBackendStore\getLocalCopyMulti(), FileBackendStore\getLocalReferenceMulti(), FileBackendStore\moveInternal(), FileBackendStore\preloadFileStat(), FileBackendStore\primeContainerCache(), FileBackendStore\primeFileCache(), FileBackendStore\storeInternal(), and FileBackendStore\streamFile().
|
final |
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.
array | $params | Parameters include:
|
Definition at line 841 of file FileBackend.php.
References $params, doSecure(), getScopedPHPBehaviorForOps(), isReadOnly(), name, and newStatus().
FileBackend::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 195 of file FileBackend.php.
References $logger.
|
staticfinal |
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.
string | $storagePath |
Definition at line 1440 of file FileBackend.php.
References captcha-old\count.
Referenced by FileBackendGroup\backendFromPath(), FileBackendStore\directoryExists(), FileBackendStore\doClean(), FSFileBackend\doCleanInternal(), FSFileBackend\doDirectoryExists(), FileBackendStore\doPrepare(), FSFileBackend\doPrepareInternal(), FileBackendStore\doPublish(), FSFileBackend\doPublishInternal(), FileBackendStore\doSecure(), FSFileBackend\doSecureInternal(), FileBackendDBRepoWrapper\getBackendPaths(), FileBackendStore\getDirectoryList(), FSFileBackend\getDirectoryListInternal(), FileBackendStore\getFileList(), FSFileBackend\getFileListInternal(), FileRepo\initDirectory(), normalizeStoragePath(), parentStoragePath(), FileBackendStore\resolveStoragePath(), FSFileBackend\resolveToFSPath(), and FileBackendTest\testSplitStoragePath().
Performs a single store operation.
This sets $params['op'] to 'store' and passes it to doOperation().
array | $params | Operation parameters |
array | $opts | Operation options |
Definition at line 481 of file FileBackend.php.
References doOperation().
|
abstract |
Stream the file at a storage path in the backend.
If the file does not exists, an HTTP 404 error will be given. Appropriate HTTP headers (Status, Content-Type, Content-Length) will be sent if streaming began, while none will be sent otherwise. Implementations should flush the output buffer before sending data.
array | $params | Parameters include:
|
Reimplemented in FileBackendStore, FileBackendMultiWrite, and FileBackendDBRepoWrapper.
|
final |
Unlock the files at the given storage paths in the backend.
array | $paths | Storage paths |
int | $type | LockManager::LOCK_* constant |
Definition at line 1314 of file FileBackend.php.
References $type, and wrapStatus().
|
finalprotected |
StatusValue | $sv |
Definition at line 1605 of file FileBackend.php.
Referenced by lockFiles(), newStatus(), and unlockFiles().
|
protected |
How many operations can be done in parallel.
Definition at line 106 of file FileBackend.php.
Referenced by FileBackendStore\doQuickOperationsInternal(), and FileBackendStore\setConcurrencyFlags().
|
protected |
Unique domain name.
Definition at line 97 of file FileBackend.php.
Referenced by FileBackendMultiWrite\__construct(), and getDomainId().
|
protected |
Definition at line 114 of file FileBackend.php.
Referenced by FileBackendMultiWrite\__construct(), and getJournal().
|
protected |
Definition at line 112 of file FileBackend.php.
|
protected |
Definition at line 116 of file FileBackend.php.
Referenced by setLogger().
|
protected |
Unique backend name.
Definition at line 94 of file FileBackend.php.
Referenced by FileBackendMultiWrite\__construct(), SwiftFileBackend\doDescribeInternal(), FileBackendDBRepoWrapper\getBackendPaths(), SwiftFileBackend\getCustomHeaders(), SwiftFileBackend\getMetadata(), SwiftFileBackend\getMetadataHeaders(), getName(), FileBackendStore\normalizeXAttributes(), and FileBackendStore\sanitizeOpHeaders().
|
protected |
Definition at line 121 of file FileBackend.php.
Referenced by FileBackendStore\doStreamFile(), and SwiftFileBackend\doStreamFile().
|
protected |
When to do operations in parallel.
Definition at line 103 of file FileBackend.php.
Class name or object With profileIn/profileOut methods.
Definition at line 118 of file FileBackend.php.
|
protected |
Read-only explanation message.
Definition at line 100 of file FileBackend.php.
|
protected |
Definition at line 125 of file FileBackend.php.
|
protected |
Definition at line 123 of file FileBackend.php.
Referenced by FileBackendStore\doStreamFile().
|
protected |
Temporary file directory.
Definition at line 109 of file FileBackend.php.
const FileBackend::ATTR_HEADERS = 1 |
Bitfield flags for supported features.
Definition at line 128 of file FileBackend.php.
Referenced by FileBackendTest\doTestDescribe(), and SwiftFileBackend\getFeatures().
const FileBackend::ATTR_METADATA = 2 |
Definition at line 129 of file FileBackend.php.
Referenced by SwiftFileBackend\getFeatures().
const FileBackend::ATTR_UNICODE_PATHS = 4 |
Definition at line 130 of file FileBackend.php.
Referenced by FileRepo\backendSupportsUnicodePaths(), MemoryFileBackend\getFeatures(), FSFileBackend\getFeatures(), SwiftFileBackend\getFeatures(), and getFeatures().