BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
FileOp Class Reference
Inheritance diagram for FileOp:

Public Member Functions

 __construct (FileBackendStore $backend, array $params)
 
 setBatchId ($batchId)
 
 getParam ($name)
 
 failed ()
 
 applyDependencies (array $deps)
 
 dependsOn (array $deps)
 
 getJournalEntries (array $oPredicates, array $nPredicates)
 
 precheck (array &$predicates)
 
 attempt ()
 
 attemptAsync ()
 
 storagePathsRead ()
 
 storagePathsChanged ()
 
 getBackend ()
 
 logFailure ($action)
 

Static Public Member Functions

static newPredicates ()
 
static newDependencies ()
 

Public Attributes

const STATE_NEW = 1
 
const STATE_CHECKED = 2
 
const STATE_ATTEMPTED = 3
 

Protected Member Functions

 doPrecheck (array &$predicates)
 
 doAttempt ()
 
 allowedParams ()
 
 setFlags (array $params)
 
 precheckDestExistence (array $predicates)
 
 getSourceSha1Base36 ()
 
 fileExists ($source, array $predicates)
 
 fileSha1 ($source, array $predicates)
 

Static Protected Member Functions

static normalizeIfValidStoragePath ($path)
 

Protected Attributes

 $params = []
 
 $backend
 
 $state = self::STATE_NEW
 
 $failed = false
 
 $async = false
 
 $batchId
 
 $doOperation = true
 
 $sourceSha1
 
 $overwriteSameCase
 
 $destExists
 

Detailed Description

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.

Since
1.19

Constructor & Destructor Documentation

FileOp::__construct ( FileBackendStore  $backend,
array  $params 
)
final

Build a new batch file operation transaction

Parameters
FileBackendStore$backend
array$params
Exceptions
FileBackendError

Member Function Documentation

FileOp::allowedParams ( )
protected

Get the file operation parameters

Returns
array (required params list, optional params list, list of params that are paths)
FileOp::applyDependencies ( array  $deps)
final

Update a dependency tracking array to account for this operation

Parameters
array$depsPrior path reads/writes; format of FileOp::newPredicates()
Returns
array
FileOp::attempt ( )
final

Attempt the operation

Returns
Status
FileOp::attemptAsync ( )
final

Attempt the operation in the background

Returns
Status
FileOp::dependsOn ( array  $deps)
final

Check if this operation changes files listed in $paths

Parameters
array$depsPrior path reads/writes; format of FileOp::newPredicates()
Returns
bool
FileOp::doAttempt ( )
protected
Returns
Status
FileOp::doPrecheck ( array &  $predicates)
protected
Parameters
array$predicates
Returns
Status
FileOp::failed ( )
final

Check if this operation failed precheck() or attempt()

Returns
bool
FileOp::fileExists (   $source,
array  $predicates 
)
finalprotected

Check if a file will exist in storage when this operation is attempted

Parameters
string$sourceStorage path
array$predicates
Returns
bool
FileOp::fileSha1 (   $source,
array  $predicates 
)
finalprotected

Get the SHA-1 of a file in storage when this operation is attempted

Parameters
string$sourceStorage path
array$predicates
Returns
string|bool False on failure
FileOp::getBackend ( )

Get the backend this operation is for

Returns
FileBackendStore
FileOp::getJournalEntries ( array  $oPredicates,
array  $nPredicates 
)
final

Get the file journal entries for this file operation

Parameters
array$oPredicatesPre-op info about files (format of FileOp::newPredicates)
array$nPredicatesPost-op info about files (format of FileOp::newPredicates)
Returns
array
FileOp::getParam (   $name)
final

Get the value of the parameter with the given name

Parameters
string$name
Returns
mixed Returns null if the parameter is not set
FileOp::getSourceSha1Base36 ( )
protected

precheckDestExistence() helper function to get the source file SHA-1. Subclasses should overwride this if the source is not in storage.

Returns
string|bool Returns false on failure
FileOp::logFailure (   $action)
final

Log a file operation failure and preserve any temp files

Parameters
string$action
static FileOp::newDependencies ( )
staticfinal

Get a new empty dependency tracking array for paths read/written to

Returns
array
static FileOp::newPredicates ( )
staticfinal

Get a new empty predicates array for precheck()

Returns
array
static FileOp::normalizeIfValidStoragePath (   $path)
staticprotected

Normalize a string if it is a valid storage path

Parameters
string$path
Returns
string
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.

Parameters
array$predicates
Returns
Status
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.

Parameters
array$predicates
Returns
Status
FileOp::setBatchId (   $batchId)
final

Set the batch UUID this operation belongs to

Parameters
string$batchId
FileOp::setFlags ( array  $params)
protected

Adjust params to FileBackendStore internal file calls

Parameters
array$params
Returns
array (required params list, optional params list)
FileOp::storagePathsChanged ( )

Get a list of storage paths written to for this operation

Returns
array
FileOp::storagePathsRead ( )

Get a list of storage paths read from for this operation

Returns
array

The documentation for this class was generated from the following file: