|
MediaWiki
REL1_23
|
FileBackend helper class for representing operations. More...


Public Member Functions | |
| __construct (FileBackendStore $backend, array $params) | |
| 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. | |
| 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) | |
| 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. | |
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 | $destExists |
| * | |
| bool | $doOperation = true |
| Operation is not a no-op *. | |
| bool | $failed = false |
| * | |
| bool | $overwriteSameCase |
| * | |
| array | $params = array() |
| * | |
| string | $sourceSha1 |
| * | |
| int | $state = self::STATE_NEW |
| * | |
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 batch file operation transaction.
| FileBackendStore | $backend | |
| array | $params |
| FileBackendError |
Definition at line 69 of file FileOp.php.
References $backend, $name, allowedParams(), as, list, and normalizeIfValidStoragePath().
| FileOp::allowedParams | ( | ) | [protected] |
Get the file operation parameters.
Reimplemented in DescribeFileOp, DeleteFileOp, MoveFileOp, CopyFileOp, StoreFileOp, and CreateFileOp.
Definition at line 308 of file FileOp.php.
Referenced by __construct().
| FileOp::applyDependencies | ( | array $ | deps | ) | [final] |
Update a dependency tracking array to account for this operation.
| array | $deps | Prior path reads/writes; format of FileOp::newPredicates() |
Definition at line 160 of file FileOp.php.
References array().
| FileOp::attempt | ( | ) | [final] |
| FileOp::attemptAsync | ( | ) | [final] |
| FileOp::dependsOn | ( | array $ | deps | ) | [final] |
Check if this operation changes files listed in $paths.
| array | $deps | Prior path reads/writes; format of FileOp::newPredicates() |
Definition at line 173 of file FileOp.php.
| FileOp::doAttempt | ( | ) | [protected] |
Reimplemented in DescribeFileOp, DeleteFileOp, MoveFileOp, CopyFileOp, StoreFileOp, and CreateFileOp.
Definition at line 286 of file FileOp.php.
| FileOp::doPrecheck | ( | array &$ | predicates | ) | [protected] |
| array | $predicates |
Reimplemented in DescribeFileOp, DeleteFileOp, MoveFileOp, CopyFileOp, StoreFileOp, and CreateFileOp.
Definition at line 254 of file FileOp.php.
| FileOp::failed | ( | ) | [final] |
Check if this operation failed precheck() or attempt()
Definition at line 132 of file FileOp.php.
| FileOp::fileExists | ( | $ | source, |
| array $ | predicates | ||
| ) | [final, protected] |
Check if a file will exist in storage when this operation is attempted.
| string | $source | Storage path |
| array | $predicates |
Definition at line 400 of file FileOp.php.
Referenced by DeleteFileOp\doPrecheck(), and DescribeFileOp\doPrecheck().
| FileOp::fileSha1 | ( | $ | source, |
| array $ | predicates | ||
| ) | [final, protected] |
Get the SHA-1 of a file in storage when this operation is attempted.
| string | $source | Storage path |
| array | $predicates |
Definition at line 417 of file FileOp.php.
Get the backend this operation is for.
Definition at line 434 of file FileOp.php.
| FileOp::getJournalEntries | ( | array $ | oPredicates, |
| array $ | nPredicates | ||
| ) | [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 195 of file FileOp.php.
| FileOp::getParam | ( | $ | name | ) | [final] |
Get the value of the parameter with the given name.
| string | $name |
Definition at line 123 of file FileOp.php.
References $batchId.
Referenced by DeleteFileOp\doPrecheck().
| FileOp::getSourceSha1Base36 | ( | ) | [protected] |
precheckDestExistence() helper function to get the source file SHA-1.
Subclasses should overwride this if the source is not in storage.
Reimplemented in StoreFileOp, and CreateFileOp.
Definition at line 389 of file FileOp.php.
| FileOp::logFailure | ( | $ | action | ) | [final] |
Log a file operation failure and preserve any temp files.
| string | $action |
Definition at line 443 of file FileOp.php.
| static FileOp::newDependencies | ( | ) | [static, final] |
Get a new empty dependency tracking array for paths read/written to.
Definition at line 150 of file FileOp.php.
Referenced by FileOpBatch\attempt().
| static FileOp::newPredicates | ( | ) | [static, final] |
Get a new empty predicates array for precheck()
Definition at line 141 of file FileOp.php.
Referenced by FileOpBatch\attempt().
| static FileOp::normalizeIfValidStoragePath | ( | $ | path | ) | [static, protected] |
Normalize a string if it is a valid storage path.
| string | $path |
Definition at line 98 of file FileOp.php.
Referenced by __construct().
| FileOp::precheck | ( | array &$ | predicates | ) | [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 status object is returned.
| array | $predicates |
Definition at line 237 of file FileOp.php.
| FileOp::precheckDestExistence | ( | array $ | predicates | ) | [protected] |
Check for errors with regards to the destination file already existing.
Also set the destExists, overwriteSameCase and sourceSha1 member variables. A bad status will be returned if there is no chance it can be overwritten.
| array | $predicates |
Definition at line 348 of file FileOp.php.
| FileOp::setBatchId | ( | $ | batchId | ) | [final] |
Set the batch UUID this operation belongs to.
| string | $batchId |
Definition at line 113 of file FileOp.php.
| FileOp::setFlags | ( | array $ | params | ) | [protected] |
Adjust params to FileBackendStore internal file calls.
| array | $params |
Definition at line 318 of file FileOp.php.
References array().
Referenced by StoreFileOp\getSourceSha1Base36().
Get a list of storage paths written to for this operation.
Reimplemented in DescribeFileOp, DeleteFileOp, MoveFileOp, CopyFileOp, StoreFileOp, and CreateFileOp.
Definition at line 336 of file FileOp.php.
Get a list of storage paths read from for this operation.
Reimplemented in MoveFileOp, and CopyFileOp.
Definition at line 327 of file FileOp.php.
bool FileOp::$async = false [protected] |
*
Definition at line 45 of file FileOp.php.
FileBackendStore FileOp::$backend [protected] |
string FileOp::$batchId [protected] |
bool FileOp::$destExists [protected] |
*
Definition at line 55 of file FileOp.php.
bool FileOp::$doOperation = true [protected] |
Operation is not a no-op *.
Definition at line 49 of file FileOp.php.
*
Definition at line 43 of file FileOp.php.
bool FileOp::$overwriteSameCase [protected] |
*
Definition at line 53 of file FileOp.php.
*
Definition at line 37 of file FileOp.php.
string FileOp::$sourceSha1 [protected] |
*
Definition at line 51 of file FileOp.php.
int FileOp::$state = self::STATE_NEW [protected] |
*
Definition at line 41 of file FileOp.php.
| const FileOp::STATE_ATTEMPTED = 3 |
Definition at line 60 of file FileOp.php.
| const FileOp::STATE_CHECKED = 2 |
Definition at line 59 of file FileOp.php.
| const FileOp::STATE_NEW = 1 |
Definition at line 58 of file FileOp.php.