MediaWiki master
|
FileBackend helper class for representing operations. More...
Inherited by CopyFileOp, CreateFileOp, DeleteFileOp, DescribeFileOp, MoveFileOp, NullFileOp, and StoreFileOp.
Public Member Functions | |
__construct (FileBackendStore $backend, array $params, LoggerInterface $logger) | |
Build a new batch file operation transaction. | |
applyDependencies (array $deps) | |
Update a dependency tracking array to account for this operation. | |
attempt () | |
Attempt the operation. | |
attemptAsync () | |
Attempt the operation in the background. | |
attemptAsyncQuick () | |
Attempt the operation in the background without regards to prechecks. | |
attemptQuick () | |
Attempt the operation without regards to prechecks. | |
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. | |
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 (FileStatePredicates $predicates) | |
Do a dry-run precondition check of the operation in the context of op batch. | |
storagePathsChanged () | |
Get a list of storage paths written to for this operation. | |
storagePathsRead () | |
Get a list of storage paths read from for this operation. | |
storagePathsReadOrChanged () | |
Get a list of storage paths read from or written to for this operation. | |
Static Public Member Functions | |
static | newDependencies () |
Get a new empty dependency tracking array for paths read/written to. | |
Protected Member Functions | |
allowedParams () | |
Get the file operation parameters. | |
doAttempt () | |
doPrecheck (FileStatePredicates $opPredicates, FileStatePredicates $batchPredicates) | |
Do a dry-run precondition check of the operation in the context of op batch. | |
precheckDestExistence (FileStatePredicates $opPredicates, $sourceSize, $sourceSha1) | |
Check for errors with regards to the destination file already existing. | |
resolveFileExistence ( $source, FileStatePredicates $opPredicates) | |
Check if a file will exist in storage when this operation is attempted. | |
resolveFileSha1Base36 ( $source, FileStatePredicates $opPredicates) | |
Get the SHA-1 of a file in storage when this operation is attempted. | |
resolveFileSize ( $source, FileStatePredicates $opPredicates) | |
Get the size a file in storage will have when this operation is attempted. | |
setFlags (array $params) | |
Adjust params to FileBackendStore internal file calls. | |
Static Protected Member Functions | |
static | normalizeIfValidStoragePath ( $path) |
Normalize a string if it is a valid storage path. | |
Protected Attributes | |
bool | $async = false |
Whether the operation is part of a concurrent sub-batch of operation. | |
FileBackendStore | $backend |
bool null | $destExists |
bool | $failed = false |
Whether the operation pre-check or attempt stage failed. | |
LoggerInterface | $logger |
bool | $noOp = false |
Whether the operation pre-check stage marked the attempt stage as a no-op. | |
bool null | $overwriteSameCase |
array | $params = [] |
int | $state = self::STATE_NEW |
Stage in the operation life-cycle. | |
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 40 of file FileOp.php.
|
final |
Build a new batch file operation transaction.
FileBackendStore | $backend | |
array | $params | |
LoggerInterface | $logger | PSR logger instance |
InvalidArgumentException |
Definition at line 78 of file FileOp.php.
References $backend, $logger, $params, allowedParams(), and normalizeIfValidStoragePath().
|
protected |
Get the file operation parameters.
Reimplemented in CopyFileOp, CreateFileOp, DeleteFileOp, DescribeFileOp, MoveFileOp, and StoreFileOp.
Definition at line 303 of file FileOp.php.
Referenced by __construct().
|
final |
Update a dependency tracking array to account for this operation.
array | $deps | Prior path reads/writes; format of FileOp::newDependencies() |
Definition at line 154 of file FileOp.php.
References storagePathsChanged(), and storagePathsRead().
|
final |
Attempt the operation.
Definition at line 236 of file FileOp.php.
References doAttempt(), failed(), and logFailure().
Referenced by attemptAsync(), and attemptQuick().
|
final |
Attempt the operation in the background.
Definition at line 268 of file FileOp.php.
References attempt().
Referenced by attemptAsyncQuick().
|
final |
Attempt the operation in the background without regards to prechecks.
Definition at line 292 of file FileOp.php.
References attemptAsync().
|
final |
Attempt the operation without regards to prechecks.
Definition at line 281 of file FileOp.php.
References attempt().
|
final |
Check if this operation changes files listed in $paths.
array | $deps | Prior path reads/writes; format of FileOp::newDependencies() |
Definition at line 167 of file FileOp.php.
References $path, storagePathsChanged(), and storagePathsRead().
|
protected |
Reimplemented in CopyFileOp, CreateFileOp, DeleteFileOp, DescribeFileOp, MoveFileOp, and StoreFileOp.
Definition at line 259 of file FileOp.php.
Referenced by attempt().
|
protected |
Do a dry-run precondition check of the operation in the context of op batch.
Updates the batch predicates for all paths this op can change if an OK status is returned
FileStatePredicates | $opPredicates | Counterfactual file states for op paths at op start |
FileStatePredicates | $batchPredicates | Counterfactual file states for the op batch |
Reimplemented in CopyFileOp, CreateFileOp, DeleteFileOp, DescribeFileOp, MoveFileOp, and StoreFileOp.
Definition at line 224 of file FileOp.php.
Referenced by precheck().
|
final |
Check if this operation failed precheck() or attempt()
Definition at line 135 of file FileOp.php.
References $failed.
Referenced by attempt(), and precheck().
FileOp::getBackend | ( | ) |
Get the backend this operation is for.
Definition at line 457 of file FileOp.php.
References $backend.
|
final |
Get the value of the parameter with the given name.
string | $name |
Definition at line 126 of file FileOp.php.
Referenced by CopyFileOp\doAttempt(), MoveFileOp\doAttempt(), CopyFileOp\doPrecheck(), DeleteFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and precheckDestExistence().
|
final |
Log a file operation failure and preserve any temp files.
string | $action |
Definition at line 466 of file FileOp.php.
References $params.
Referenced by attempt().
|
staticfinal |
Get a new empty dependency tracking array for paths read/written to.
Definition at line 144 of file FileOp.php.
Referenced by FileOpBatch\attempt().
|
staticprotected |
Normalize a string if it is a valid storage path.
string | $path |
Definition at line 110 of file FileOp.php.
References $path.
Referenced by __construct().
|
final |
Do a dry-run precondition check of the operation in the context of op batch.
Updates the batch predicates for all paths this op can change if an OK status is returned
FileStatePredicates | $predicates | Counterfactual file states for the op batch |
Definition at line 190 of file FileOp.php.
References $path, doPrecheck(), failed(), FileStatePredicates\snapshot(), and storagePathsReadOrChanged().
|
protected |
Check for errors with regards to the destination file already existing.
Also set the destExists and overwriteSameCase member variables. A bad StatusValue will be returned if there is no chance it can be overwritten.
FileStatePredicates | $opPredicates | Counterfactual storage path states for this op |
int | false | Closure | $sourceSize | Source size or idempotent function yielding the size |
string | Closure | $sourceSha1 | Source hash, or, idempotent function yielding the hash |
Definition at line 357 of file FileOp.php.
References getParam(), resolveFileExistence(), resolveFileSha1Base36(), and resolveFileSize().
Referenced by CopyFileOp\doPrecheck(), CreateFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and StoreFileOp\doPrecheck().
|
finalprotected |
Check if a file will exist in storage when this operation is attempted.
Ideally, the file stat entry should already be preloaded via preloadFileStat(). Otherwise, this will query the backend.
string | $source | Storage path |
FileStatePredicates | $opPredicates | Counterfactual storage path states for this op |
Definition at line 407 of file FileOp.php.
References $path, $source, and FileStatePredicates\resolveFileExistence().
Referenced by CopyFileOp\doPrecheck(), DeleteFileOp\doPrecheck(), DescribeFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and precheckDestExistence().
|
finalprotected |
Get the SHA-1 of a file in storage when this operation is attempted.
string | $source | Storage path |
FileStatePredicates | $opPredicates | Counterfactual storage path states for this op |
Definition at line 443 of file FileOp.php.
References $path, $source, and FileStatePredicates\resolveFileSha1Base36().
Referenced by CopyFileOp\doPrecheck(), DescribeFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and precheckDestExistence().
|
finalprotected |
Get the size a file in storage will have when this operation is attempted.
Ideally, file the stat entry should already be preloaded via preloadFileStat() and the backend tracks hashes as extended attributes. Otherwise, this will query the backend. Get the size of a file in storage when this operation is attempted
string | $source | Storage path |
FileStatePredicates | $opPredicates | Counterfactual storage path states for this op |
Definition at line 427 of file FileOp.php.
References $path, $source, and FileStatePredicates\resolveFileSize().
Referenced by CopyFileOp\doPrecheck(), DescribeFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and precheckDestExistence().
|
protected |
Adjust params to FileBackendStore internal file calls.
array | $params |
Definition at line 313 of file FileOp.php.
References $async, and $params.
Referenced by CopyFileOp\doAttempt(), CreateFileOp\doAttempt(), DeleteFileOp\doAttempt(), DescribeFileOp\doAttempt(), MoveFileOp\doAttempt(), and StoreFileOp\doAttempt().
FileOp::storagePathsChanged | ( | ) |
Get a list of storage paths written to for this operation.
Reimplemented in CopyFileOp, CreateFileOp, DeleteFileOp, DescribeFileOp, MoveFileOp, and StoreFileOp.
Definition at line 331 of file FileOp.php.
Referenced by applyDependencies(), dependsOn(), and storagePathsReadOrChanged().
FileOp::storagePathsRead | ( | ) |
Get a list of storage paths read from for this operation.
Reimplemented in CopyFileOp, and MoveFileOp.
Definition at line 322 of file FileOp.php.
Referenced by applyDependencies(), dependsOn(), and storagePathsReadOrChanged().
|
final |
Get a list of storage paths read from or written to for this operation.
Definition at line 340 of file FileOp.php.
References storagePathsChanged(), and storagePathsRead().
Referenced by precheck().
|
protected |
Whether the operation is part of a concurrent sub-batch of operation.
Definition at line 54 of file FileOp.php.
Referenced by setFlags().
|
protected |
Definition at line 42 of file FileOp.php.
Referenced by __construct(), and getBackend().
|
protected |
Definition at line 61 of file FileOp.php.
Referenced by CopyFileOp\doPrecheck(), CreateFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and StoreFileOp\doPrecheck().
|
protected |
Whether the operation pre-check or attempt stage failed.
Definition at line 52 of file FileOp.php.
Referenced by failed().
|
protected |
Definition at line 44 of file FileOp.php.
Referenced by __construct().
|
protected |
Whether the operation pre-check stage marked the attempt stage as a no-op.
Definition at line 56 of file FileOp.php.
|
protected |
Definition at line 59 of file FileOp.php.
|
protected |
Definition at line 47 of file FileOp.php.
Referenced by __construct(), logFailure(), and setFlags().
|
protected |
Stage in the operation life-cycle.
Definition at line 50 of file FileOp.php.