MediaWiki
REL1_20
|
FileBackend helper class for representing operations. More...
Public Member Functions | |
__construct (FileBackendStore $backend, array $params) | |
Build a new file operation transaction. | |
allowStaleReads ($allowStale) | |
Whether to allow stale data for file reads and stat checks. | |
applyDependencies (array $deps) | |
Update a dependency tracking array to account for this operation. | |
attempt () | |
Attempt the operation. | |
attemptAsync () | |
Attempt the operation in the background. | |
dependsOn (array $deps) | |
Check if this operation changes files listed in $paths. | |
failed () | |
Check if this operation failed precheck() or attempt() | |
getBackend () | |
Get the backend this operation is for. | |
getJournalEntries (array $oPredicates, array $nPredicates) | |
Get the file journal entries for this file operation. | |
getParam ($name) | |
Get the value of the parameter with the given name. | |
logFailure ($action) | |
Log a file operation failure and preserve any temp files. | |
precheck (array &$predicates) | |
Check preconditions of the operation without writing anything. | |
setBatchId ($batchId) | |
Set the batch UUID this operation belongs to. | |
storagePathsChanged () | |
Get a list of storage paths written to for this operation. | |
storagePathsRead () | |
Get a list of storage paths read from for this operation. | |
Static Public Member Functions | |
static | newDependencies () |
Get a new empty dependency tracking array for paths read/written to. | |
static | newPredicates () |
Get a new empty predicates array for precheck() | |
Public Attributes | |
const | STATE_ATTEMPTED = 3 |
const | STATE_CHECKED = 2 |
const | STATE_NEW = 1 |
Protected Member Functions | |
allowedParams () | |
Get the file operation parameters. | |
doAttempt () | |
doPrecheck (array &$predicates) | |
doStoragePathsChanged () | |
doStoragePathsRead () | |
fileExists ($source, array $predicates) | |
Check if a file will exist in storage when this operation is attempted. | |
fileSha1 ($source, array $predicates) | |
Get the SHA-1 of a file in storage when this operation is attempted. | |
getSourceSha1Base36 () | |
precheckDestExistence() helper function to get the source file SHA-1. | |
precheckDestExistence (array $predicates) | |
Check for errors with regards to the destination file already existing. | |
setFlags (array $params) | |
Adjust params to FileBackendStore internal file calls. | |
Protected Attributes | |
$async = false | |
FileBackendStore | $backend |
* | |
$batchId | |
$destSameAsSource | |
$failed = false | |
Array | $params = array() |
* | |
$sourceSha1 | |
$state = self::STATE_NEW | |
$useLatest = true |
FileBackend helper class for representing operations.
Do not use this class from places outside FileBackend.
Methods called from FileOpBatch::attempt() should avoid throwing exceptions at all costs. FileOp objects should be lightweight in order to support large arrays in memory and serialization.
Definition at line 36 of file FileOp.php.
FileOp::__construct | ( | FileBackendStore $ | backend, |
array $ | params | ||
) | [final] |
Build a new file operation transaction.
$backend | FileBackendStore |
$params | Array |
MWException |
Definition at line 61 of file FileOp.php.
FileOp::allowedParams | ( | ) | [protected] |
Get the file operation parameters.
Reimplemented in DeleteFileOp, MoveFileOp, CopyFileOp, CreateFileOp, and StoreFileOp.
Definition at line 274 of file FileOp.php.
FileOp::allowStaleReads | ( | $ | allowStale | ) | [final] |
Whether to allow stale data for file reads and stat checks.
$allowStale | bool |
Definition at line 95 of file FileOp.php.
FileOp::applyDependencies | ( | array $ | deps | ) | [final] |
Update a dependency tracking array to account for this operation.
$deps | Array Prior path reads/writes; format of FileOp::newPredicates() |
Definition at line 142 of file FileOp.php.
FileOp::attempt | ( | ) | [final] |
FileOp::attemptAsync | ( | ) | [final] |
FileOp::dependsOn | ( | array $ | deps | ) | [final] |
Check if this operation changes files listed in $paths.
$paths | Array Prior path reads/writes; format of FileOp::newPredicates() |
Definition at line 154 of file FileOp.php.
FileOp::doAttempt | ( | ) | [protected] |
Reimplemented in DeleteFileOp, MoveFileOp, CopyFileOp, CreateFileOp, and StoreFileOp.
Definition at line 253 of file FileOp.php.
FileOp::doPrecheck | ( | array &$ | predicates | ) | [protected] |
Reimplemented in DeleteFileOp, MoveFileOp, CopyFileOp, CreateFileOp, and StoreFileOp.
Definition at line 226 of file FileOp.php.
FileOp::doStoragePathsChanged | ( | ) | [protected] |
Reimplemented in DeleteFileOp, MoveFileOp, CopyFileOp, CreateFileOp, and StoreFileOp.
Definition at line 318 of file FileOp.php.
FileOp::doStoragePathsRead | ( | ) | [protected] |
Reimplemented in MoveFileOp, and CopyFileOp.
Definition at line 301 of file FileOp.php.
FileOp::failed | ( | ) | [final] |
Check if this operation failed precheck() or attempt()
Definition at line 114 of file FileOp.php.
FileOp::fileExists | ( | $ | source, |
array $ | predicates | ||
) | [final, protected] |
Check if a file will exist in storage when this operation is attempted.
$source | string Storage path |
$predicates | Array |
Definition at line 378 of file FileOp.php.
FileOp::fileSha1 | ( | $ | source, |
array $ | predicates | ||
) | [final, protected] |
Get the SHA-1 of a file in storage when this operation is attempted.
$source | string Storage path |
$predicates | Array |
Definition at line 394 of file FileOp.php.
Get the backend this operation is for.
Definition at line 408 of file FileOp.php.
FileOp::getJournalEntries | ( | array $ | oPredicates, |
array $ | nPredicates | ||
) | [final] |
Get the file journal entries for this file operation.
$oPredicates | Array Pre-op info about files (format of FileOp::newPredicates) |
$nPredicates | Array Post-op info about files (format of FileOp::newPredicates) |
Definition at line 175 of file FileOp.php.
FileOp::getParam | ( | $ | name | ) | [final] |
Get the value of the parameter with the given name.
$name | string |
Definition at line 105 of file FileOp.php.
FileOp::getSourceSha1Base36 | ( | ) | [protected] |
precheckDestExistence() helper function to get the source file SHA-1.
Subclasses should overwride this iff the source is not in storage.
Reimplemented in CreateFileOp, and StoreFileOp.
Definition at line 367 of file FileOp.php.
FileOp::logFailure | ( | $ | action | ) | [final] |
Log a file operation failure and preserve any temp files.
$action | string |
Definition at line 418 of file FileOp.php.
static FileOp::newDependencies | ( | ) | [static, final] |
Get a new empty dependency tracking array for paths read/written to.
Definition at line 132 of file FileOp.php.
Referenced by FileOpBatch\attempt().
static FileOp::newPredicates | ( | ) | [static, final] |
Get a new empty predicates array for precheck()
Definition at line 123 of file FileOp.php.
Referenced by FileOpBatch\attempt().
FileOp::precheck | ( | array &$ | predicates | ) | [final] |
Check preconditions of the operation without writing anything.
$predicates | Array |
Definition at line 211 of file FileOp.php.
FileOp::precheckDestExistence | ( | array $ | predicates | ) | [protected] |
Check for errors with regards to the destination file already existing.
This also updates the destSameAsSource and sourceSha1 member variables. A bad status will be returned if there is no chance it can be overwritten.
$predicates | Array |
Definition at line 330 of file FileOp.php.
FileOp::setBatchId | ( | $ | batchId | ) | [final] |
Set the batch UUID this operation belongs to.
$batchId | string |
Definition at line 85 of file FileOp.php.
FileOp::setFlags | ( | array $ | params | ) | [protected] |
Adjust params to FileBackendStore internal file calls.
$params | Array |
Definition at line 284 of file FileOp.php.
FileOp::storagePathsChanged | ( | ) | [final] |
Get a list of storage paths written to for this operation.
Definition at line 310 of file FileOp.php.
FileOp::storagePathsRead | ( | ) | [final] |
Get a list of storage paths read from for this operation.
Definition at line 293 of file FileOp.php.
FileOp::$async = false [protected] |
Definition at line 42 of file FileOp.php.
FileBackendStore FileOp::$backend [protected] |
*
Definition at line 38 of file FileOp.php.
FileOp::$batchId [protected] |
Definition at line 44 of file FileOp.php.
FileOp::$destSameAsSource [protected] |
Definition at line 47 of file FileOp.php.
Definition at line 41 of file FileOp.php.
Array FileOp::$params = array() [protected] |
*
Definition at line 37 of file FileOp.php.
FileOp::$sourceSha1 [protected] |
Definition at line 46 of file FileOp.php.
FileOp::$state = self::STATE_NEW [protected] |
Definition at line 40 of file FileOp.php.
FileOp::$useLatest = true [protected] |
Definition at line 43 of file FileOp.php.
const FileOp::STATE_ATTEMPTED = 3 |
Definition at line 52 of file FileOp.php.
const FileOp::STATE_CHECKED = 2 |
Definition at line 51 of file FileOp.php.
const FileOp::STATE_NEW = 1 |
Definition at line 50 of file FileOp.php.