MediaWiki fundraising/REL1_35
|
FileBackend helper class for representing operations. More...
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. | |
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. | |
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. | |
static | newPredicates () |
Get a new empty predicates array for precheck() | |
Protected Member Functions | |
allowedParams () | |
Get the file operation parameters. | |
doAttempt () | |
doPrecheck (array &$predicates) | |
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. | |
fileSize ( $source, array $predicates) | |
Get the size a file in storage will have when this operation is attempted. | |
getSourceSha1Base36 () | |
precheckDestExistence() helper function to get the source file SHA-1. | |
getSourceSize () | |
precheckDestExistence() helper function to get the source file size. | |
precheckDestExistence (array $predicates) | |
Check for errors with regards to the destination file already existing. | |
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 |
FileBackendStore | $backend |
string | $batchId |
bool | $cancelled = false |
bool | $destExists |
bool | $failed = false |
LoggerInterface | $logger |
bool | $overwriteSameCase |
array | $params = [] |
string bool | $sourceSha1 |
int bool | $sourceSize |
int | $state = self::STATE_NEW |
const | ASSUMED_EXISTS = 'exists' |
const | ASSUMED_SHA1 = 'sha1' |
const | ASSUMED_SIZE = 'size' |
Private Attributes | |
const | STATE_ATTEMPTED = 3 |
const | STATE_CHECKED = 2 |
const | STATE_NEW = 1 |
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.
|
final |
Build a new batch file operation transaction.
FileBackendStore | $backend | |
array | $params | |
LoggerInterface | $logger | PSR logger instance |
InvalidArgumentException |
Definition at line 84 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 358 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::newPredicates() |
Definition at line 178 of file FileOp.php.
References storagePathsChanged(), and storagePathsRead().
|
final |
Attempt the operation.
Definition at line 291 of file FileOp.php.
References doAttempt(), failed(), logFailure(), and STATE_ATTEMPTED.
Referenced by attemptAsync(), and attemptQuick().
|
final |
Attempt the operation in the background.
Definition at line 323 of file FileOp.php.
References attempt().
Referenced by attemptAsyncQuick().
|
final |
Attempt the operation in the background without regards to prechecks.
Definition at line 347 of file FileOp.php.
References attemptAsync(), and STATE_CHECKED.
|
final |
Attempt the operation without regards to prechecks.
Definition at line 336 of file FileOp.php.
References attempt(), and STATE_CHECKED.
|
final |
Check if this operation changes files listed in $paths.
array | $deps | Prior path reads/writes; format of FileOp::newPredicates() |
Definition at line 191 of file FileOp.php.
References $path, storagePathsChanged(), and storagePathsRead().
|
protected |
Reimplemented in CopyFileOp, CreateFileOp, DeleteFileOp, DescribeFileOp, MoveFileOp, and StoreFileOp.
Definition at line 314 of file FileOp.php.
Referenced by attempt().
|
protected |
array | &$predicates |
Reimplemented in CopyFileOp, CreateFileOp, DeleteFileOp, DescribeFileOp, MoveFileOp, and StoreFileOp.
Definition at line 282 of file FileOp.php.
Referenced by precheck().
|
final |
Check if this operation failed precheck() or attempt()
Definition at line 150 of file FileOp.php.
References $failed.
Referenced by attempt(), and precheck().
|
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 |
array | $predicates |
Definition at line 483 of file FileOp.php.
References $params, $source, ASSUMED_EXISTS, and true.
Referenced by CopyFileOp\doPrecheck(), DeleteFileOp\doPrecheck(), DescribeFileOp\doPrecheck(), MoveFileOp\doPrecheck(), getJournalEntries(), and precheckDestExistence().
|
finalprotected |
Get the SHA-1 of a file in storage when this operation is attempted.
string | $source | Storage path |
array | $predicates |
Definition at line 526 of file FileOp.php.
References $params, $source, ASSUMED_SHA1, and true.
Referenced by DescribeFileOp\doPrecheck(), getJournalEntries(), 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 |
array | $predicates |
Definition at line 504 of file FileOp.php.
References $params, $source, ASSUMED_SIZE, and true.
Referenced by DescribeFileOp\doPrecheck(), and precheckDestExistence().
FileOp::getBackend | ( | ) |
Get the backend this operation is for.
Definition at line 546 of file FileOp.php.
References $backend.
|
final |
Get the file journal entries for this file operation.
array | $oPredicates | Pre-op info about files (format of FileOp::newPredicates) |
array | $nPredicates | Post-op info about files (format of FileOp::newPredicates) |
Definition at line 213 of file FileOp.php.
References $path, ASSUMED_SHA1, fileExists(), fileSha1(), storagePathsChanged(), and storagePathsReadOrChanged().
|
final |
Get the value of the parameter with the given name.
string | $name |
Definition at line 141 of file FileOp.php.
Referenced by CopyFileOp\doAttempt(), MoveFileOp\doAttempt(), CopyFileOp\doPrecheck(), CreateFileOp\doPrecheck(), DeleteFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and precheckDestExistence().
|
protected |
precheckDestExistence() helper function to get the source file SHA-1.
Subclasses should overwrite this if the source is not in storage.
Reimplemented in CreateFileOp, and StoreFileOp.
Definition at line 469 of file FileOp.php.
Referenced by precheckDestExistence().
|
protected |
precheckDestExistence() helper function to get the source file size.
Subclasses should overwrite this if the source is not in storage.
Reimplemented in CreateFileOp, and StoreFileOp.
Definition at line 459 of file FileOp.php.
Referenced by precheckDestExistence().
|
final |
Log a file operation failure and preserve any temp files.
string | $action |
Definition at line 555 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 168 of file FileOp.php.
Referenced by FileOpBatch\attempt().
|
staticfinal |
Get a new empty predicates array for precheck()
Definition at line 159 of file FileOp.php.
Referenced by FileOpBatch\attempt().
|
staticprotected |
Normalize a string if it is a valid storage path.
string | $path |
Definition at line 116 of file FileOp.php.
References $path, $res, FileBackend\isStoragePath(), and FileBackend\normalizeStoragePath().
Referenced by __construct().
|
final |
Check preconditions of the operation without writing anything.
This must update $predicates for each path that the op can change except when a failing StatusValue object is returned.
array | &$predicates |
Definition at line 254 of file FileOp.php.
References $path, doPrecheck(), failed(), STATE_CHECKED, and storagePathsReadOrChanged().
|
protected |
Check for errors with regards to the destination file already existing.
Also set destExists, overwriteSameCase, sourceSize, and sourceSha1 member variables. A bad StatusValue will be returned if there is no chance it can be overwritten.
array | $predicates |
Definition at line 409 of file FileOp.php.
References fileExists(), fileSha1(), fileSize(), getParam(), getSourceSha1Base36(), and getSourceSize().
Referenced by CopyFileOp\doPrecheck(), CreateFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and StoreFileOp\doPrecheck().
|
final |
Set the batch UUID this operation belongs to.
string | $batchId |
Definition at line 131 of file FileOp.php.
References $batchId.
|
protected |
Adjust params to FileBackendStore internal file calls.
array | $params |
Definition at line 368 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 386 of file FileOp.php.
Referenced by applyDependencies(), dependsOn(), getJournalEntries(), and storagePathsReadOrChanged().
FileOp::storagePathsRead | ( | ) |
Get a list of storage paths read from for this operation.
Reimplemented in CopyFileOp, and MoveFileOp.
Definition at line 377 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 395 of file FileOp.php.
References storagePathsChanged(), and storagePathsRead().
Referenced by getJournalEntries(), and precheck().
|
protected |
Definition at line 50 of file FileOp.php.
Referenced by setFlags().
|
protected |
Definition at line 38 of file FileOp.php.
Referenced by __construct(), and getBackend().
|
protected |
Definition at line 52 of file FileOp.php.
Referenced by setBatchId().
|
protected |
Definition at line 54 of file FileOp.php.
|
protected |
Definition at line 65 of file FileOp.php.
Referenced by CopyFileOp\doPrecheck(), CreateFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and StoreFileOp\doPrecheck().
|
protected |
Definition at line 48 of file FileOp.php.
Referenced by failed().
|
protected |
Definition at line 40 of file FileOp.php.
Referenced by __construct().
|
protected |
Definition at line 62 of file FileOp.php.
|
protected |
Definition at line 43 of file FileOp.php.
Referenced by __construct(), fileExists(), fileSha1(), fileSize(), logFailure(), and setFlags().
|
protected |
Definition at line 59 of file FileOp.php.
Referenced by CopyFileOp\doPrecheck(), CreateFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and StoreFileOp\doPrecheck().
|
protected |
Definition at line 57 of file FileOp.php.
Referenced by CopyFileOp\doPrecheck(), CreateFileOp\doPrecheck(), MoveFileOp\doPrecheck(), and StoreFileOp\doPrecheck().
|
protected |
Definition at line 46 of file FileOp.php.
|
protected |
Definition at line 73 of file FileOp.php.
Referenced by CopyFileOp\doPrecheck(), CreateFileOp\doPrecheck(), DeleteFileOp\doPrecheck(), DescribeFileOp\doPrecheck(), MoveFileOp\doPrecheck(), StoreFileOp\doPrecheck(), and fileExists().
|
protected |
Definition at line 72 of file FileOp.php.
Referenced by CopyFileOp\doPrecheck(), CreateFileOp\doPrecheck(), DeleteFileOp\doPrecheck(), DescribeFileOp\doPrecheck(), MoveFileOp\doPrecheck(), StoreFileOp\doPrecheck(), fileSha1(), and getJournalEntries().
|
protected |
Definition at line 74 of file FileOp.php.
Referenced by CopyFileOp\doPrecheck(), CreateFileOp\doPrecheck(), DeleteFileOp\doPrecheck(), DescribeFileOp\doPrecheck(), MoveFileOp\doPrecheck(), StoreFileOp\doPrecheck(), and fileSize().
|
private |
Definition at line 70 of file FileOp.php.
Referenced by attempt().
|
private |
Definition at line 69 of file FileOp.php.
Referenced by attemptAsyncQuick(), attemptQuick(), and precheck().
|
private |
Definition at line 68 of file FileOp.php.