MediaWiki  1.27.4
FileBackendDBRepoWrapper Class Reference

Proxy backend that manages file layout rewriting for FileRepo. More...

Inheritance diagram for FileBackendDBRepoWrapper:
Collaboration diagram for FileBackendDBRepoWrapper:

Public Member Functions

 __construct (array $config)
 
 clearCache (array $paths=null)
 
 concatenate (array $params)
 
 directoryExists (array $params)
 
 fileExists (array $params)
 
 getBackendPath ($path, $latest=true)
 Translate a legacy "title" path to it's "sha1" counterpart. More...
 
 getBackendPaths (array $paths, $latest=true)
 Translate legacy "title" paths to their "sha1" counterparts. More...
 
 getDirectoryList (array $params)
 
 getFeatures ()
 
 getFileContentsMulti (array $params)
 
 getFileHttpUrl (array $params)
 
 getFileList (array $params)
 
 getFileProps (array $params)
 
 getFileSha1Base36 (array $params)
 
 getFileSize (array $params)
 
 getFileStat (array $params)
 
 getFileTimestamp (array $params)
 
 getFileXAttributes (array $params)
 
 getInternalBackend ()
 Get the underlying FileBackend that is being wrapped. More...
 
 getLocalCopyMulti (array $params)
 
 getLocalReferenceMulti (array $params)
 
 getPathForSHA1 ($sha1)
 Get the ultimate original storage path for a file. More...
 
 getScopedLocksForOps (array $ops, Status $status)
 
 preloadCache (array $paths)
 
 preloadFileStat (array $params)
 
 streamFile (array $params)
 
- Public Member Functions inherited from FileBackend
 __construct (array $config)
 Create a new backend instance from configuration. More...
 
 clean (array $params)
 Delete a storage directory if it is empty. More...
 
 clearCache (array $paths=null)
 Invalidate any in-process file stat and property cache. More...
 
 concatenate (array $params)
 Concatenate a list of storage files into a single file system file. More...
 
 copy (array $params, array $opts=[])
 Performs a single copy operation. More...
 
 create (array $params, array $opts=[])
 Performs a single create operation. More...
 
 delete (array $params, array $opts=[])
 Performs a single delete operation. More...
 
 describe (array $params, array $opts=[])
 Performs a single describe operation. More...
 
 directoryExists (array $params)
 Check if a directory exists at a given storage path. More...
 
 doOperation (array $op, array $opts=[])
 Same as doOperations() except it takes a single operation. More...
 
 doOperations (array $ops, array $opts=[])
 This is the main entry point into the backend for write operations. More...
 
 doQuickOperation (array $op)
 Same as doQuickOperations() except it takes a single operation. More...
 
 doQuickOperations (array $ops, array $opts=[])
 Perform a set of independent file operations on some files. More...
 
 fileExists (array $params)
 Check if a file exists at a storage path in the backend. More...
 
 getContainerStoragePath ($container)
 Get the storage path for the given container for this backend. More...
 
 getDirectoryList (array $params)
 Get an iterator to list all directories under a storage directory. More...
 
 getFeatures ()
 Get the a bitfield of extra features supported by the backend medium. More...
 
 getFileContents (array $params)
 Get the contents of a file at a storage path in the backend. More...
 
 getFileContentsMulti (array $params)
 Like getFileContents() except it takes an array of storage paths and returns a map of storage paths to strings (or null on failure). More...
 
 getFileHttpUrl (array $params)
 Return an HTTP URL to a given file that requires no authentication to use. More...
 
 getFileList (array $params)
 Get an iterator to list all stored files under a storage directory. More...
 
 getFileProps (array $params)
 Get the properties of the file at a storage path in the backend. More...
 
 getFileSha1Base36 (array $params)
 Get a SHA-1 hash of the file at a storage path in the backend. More...
 
 getFileSize (array $params)
 Get the size (bytes) of a file at a storage path in the backend. More...
 
 getFileStat (array $params)
 Get quick information about a file at a storage path in the backend. More...
 
 getFileTimestamp (array $params)
 Get the last-modified timestamp of the file at a storage path. More...
 
 getFileXAttributes (array $params)
 Get metadata about a file at a storage path in the backend. More...
 
 getJournal ()
 Get the file journal object for this backend. More...
 
 getLocalCopy (array $params)
 Get a local copy on disk of the file at a storage path in the backend. More...
 
 getLocalCopyMulti (array $params)
 Like getLocalCopy() except it takes an array of storage paths and returns a map of storage paths to TempFSFile objects (or null on failure). More...
 
 getLocalReference (array $params)
 Returns a file system file, identical to the file at a storage path. More...
 
 getLocalReferenceMulti (array $params)
 Like getLocalReference() except it takes an array of storage paths and returns a map of storage paths to FSFile objects (or null on failure). More...
 
 getName ()
 Get the unique backend name. More...
 
 getReadOnlyReason ()
 Get an explanatory message if this backend is read-only. More...
 
 getRootStoragePath ()
 Get the root storage path of this backend. More...
 
 getScopedFileLocks (array $paths, $type, Status $status, $timeout=0)
 Lock the files at the given storage paths in the backend. More...
 
 getScopedLocksForOps (array $ops, Status $status)
 Get an array of scoped locks needed for a batch of file operations. More...
 
 getTopDirectoryList (array $params)
 Same as FileBackend::getDirectoryList() except only lists directories that are immediately under the given directory. More...
 
 getTopFileList (array $params)
 Same as FileBackend::getFileList() except only lists files that are immediately under the given directory. More...
 
 getWikiId ()
 Get the wiki identifier used for this backend (possibly empty). More...
 
 hasFeatures ($bitfield)
 Check if the backend medium supports a field of extra features. More...
 
 isReadOnly ()
 Check if this backend is read-only. More...
 
 lockFiles (array $paths, $type, $timeout=0)
 Lock the files at the given storage paths in the backend. More...
 
 move (array $params, array $opts=[])
 Performs a single move operation. More...
 
 preloadCache (array $paths)
 Preload persistent file stat cache and property cache into in-process cache. More...
 
 preloadFileStat (array $params)
 Preload file stat information (concurrently if possible) into in-process cache. More...
 
 prepare (array $params)
 Prepare a storage directory for usage. More...
 
 publish (array $params)
 Remove measures to block web access to a storage directory and the container it belongs to. More...
 
 quickCopy (array $params)
 Performs a single quick copy operation. More...
 
 quickCreate (array $params)
 Performs a single quick create operation. More...
 
 quickDelete (array $params)
 Performs a single quick delete operation. More...
 
 quickDescribe (array $params)
 Performs a single quick describe operation. More...
 
 quickMove (array $params)
 Performs a single quick move operation. More...
 
 quickStore (array $params)
 Performs a single quick store operation. More...
 
 secure (array $params)
 Take measures to block web access to a storage directory and the container it belongs to. More...
 
 store (array $params, array $opts=[])
 Performs a single store operation. More...
 
 streamFile (array $params)
 Stream the file at a storage path in the backend. More...
 
 unlockFiles (array $paths, $type)
 Unlock the files at the given storage paths in the backend. More...
 

Protected Member Functions

 doClean (array $params)
 
 doOperationsInternal (array $ops, array $opts)
 
 doPrepare (array $params)
 
 doPublish (array $params)
 
 doQuickOperationsInternal (array $ops)
 
 doSecure (array $params)
 
 getDB ($index)
 Get a connection to the repo file registry DB. More...
 
 mungeOpPaths (array $ops)
 Translate legacy "title" source paths to their "sha1" counterparts. More...
 
 translateArrayResults ($function, array $params)
 Translates paths when the backend function returns results keyed by paths. More...
 
 translateSrcParams ($function, array $params)
 Translates paths found in the "src" or "srcs" keys of a params array. More...
 
- Protected Member Functions inherited from FileBackend
 doClean (array $params)
 
 doOperationsInternal (array $ops, array $opts)
 
 doPrepare (array $params)
 
 doPublish (array $params)
 
 doQuickOperationsInternal (array $ops)
 
 doSecure (array $params)
 
 getScopedPHPBehaviorForOps ()
 Enter file operation scope. More...
 
 resolveFSFileObjects (array $ops)
 Convert FSFile 'src' paths to string paths (with an 'srcRef' field set to the FSFile) More...
 

Protected Attributes

FileBackend $backend
 
Closure $dbHandleFunc
 
DBConnRef[] $dbs
 
string $repoName
 
ProcessCacheLRU $resolvedPathCache
 
- Protected Attributes inherited from FileBackend
int $concurrency
 How many operations can be done in parallel. More...
 
FileJournal $fileJournal
 
LockManager $lockManager
 
string $name
 Unique backend name. More...
 
string $parallelize
 When to do operations in parallel. More...
 
string $readOnly
 Read-only explanation message. More...
 
string $wikiId
 Unique wiki name. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from FileBackend
static extensionFromPath ($path, $case= 'lowercase')
 Get the final extension from a storage or FS path. More...
 
static isPathTraversalFree ($path)
 Check if a relative path has no directory traversals. More...
 
static isStoragePath ($path)
 Check if a given path is a "mwstore://" path. More...
 
static makeContentDisposition ($type, $filename= '')
 Build a Content-Disposition header value per RFC 6266. More...
 
static normalizeStoragePath ($storagePath)
 Normalize a storage path by cleaning up directory separators. More...
 
static parentStoragePath ($storagePath)
 Get the parent storage directory of a storage path. More...
 
static splitStoragePath ($storagePath)
 Split a storage path into a backend name, a container name, and a relative file path. More...
 
- Public Attributes inherited from FileBackend
const ATTR_HEADERS = 1
 Bitfield flags for supported features. More...
 
const ATTR_METADATA = 2
 
const ATTR_UNICODE_PATHS = 4
 
- Static Protected Member Functions inherited from FileBackend
static normalizeContainerPath ($path)
 Validate and normalize a relative storage path. More...
 

Detailed Description

Proxy backend that manages file layout rewriting for FileRepo.

LocalRepo may be configured to store files under their title names or by SHA-1. This acts as a shim in the later case, providing backwards compatability for most callers. All "public"/"deleted" zone files actually go in an "original" container and are never changed.

This requires something like thumb_handler.php and img_auth.php for client viewing of files.

Since
1.25

Definition at line 40 of file FileBackendDBRepoWrapper.php.

Constructor & Destructor Documentation

FileBackendDBRepoWrapper::__construct ( array  $config)

Definition at line 52 of file FileBackendDBRepoWrapper.php.

Member Function Documentation

FileBackendDBRepoWrapper::clearCache ( array  $paths = null)

Definition at line 246 of file FileBackendDBRepoWrapper.php.

FileBackendDBRepoWrapper::concatenate ( array  $params)

Definition at line 170 of file FileBackendDBRepoWrapper.php.

References translateSrcParams().

FileBackendDBRepoWrapper::directoryExists ( array  $params)

Definition at line 230 of file FileBackendDBRepoWrapper.php.

FileBackendDBRepoWrapper::doClean ( array  $params)
protected

Definition at line 166 of file FileBackendDBRepoWrapper.php.

FileBackendDBRepoWrapper::doOperationsInternal ( array  $ops,
array  $opts 
)
protected

Definition at line 146 of file FileBackendDBRepoWrapper.php.

References mungeOpPaths().

FileBackendDBRepoWrapper::doPrepare ( array  $params)
protected

Definition at line 154 of file FileBackendDBRepoWrapper.php.

FileBackendDBRepoWrapper::doPublish ( array  $params)
protected

Definition at line 162 of file FileBackendDBRepoWrapper.php.

FileBackendDBRepoWrapper::doQuickOperationsInternal ( array  $ops)
protected

Definition at line 150 of file FileBackendDBRepoWrapper.php.

References mungeOpPaths().

FileBackendDBRepoWrapper::doSecure ( array  $params)
protected

Definition at line 158 of file FileBackendDBRepoWrapper.php.

FileBackendDBRepoWrapper::fileExists ( array  $params)

Definition at line 174 of file FileBackendDBRepoWrapper.php.

References translateSrcParams().

FileBackendDBRepoWrapper::getBackendPath (   $path,
  $latest = true 
)

Translate a legacy "title" path to it's "sha1" counterpart.

E.g. mwstore://local-backend/local-public/a/ab/<name>.jpg => mwstore://local-backend/local-original/x/y/z/<sha1>.jpg

Parameters
string$path
bool$latest
Returns
string

Definition at line 81 of file FileBackendDBRepoWrapper.php.

References $path, and getBackendPaths().

Referenced by mungeOpPaths(), and translateSrcParams().

FileBackendDBRepoWrapper::getBackendPaths ( array  $paths,
  $latest = true 
)

Translate legacy "title" paths to their "sha1" counterparts.

E.g. mwstore://local-backend/local-public/a/ab/<name>.jpg => mwstore://local-backend/local-original/x/y/z/<sha1>.jpg

Parameters
array$paths
bool$latest
Returns
array Translated paths in same order

Definition at line 96 of file FileBackendDBRepoWrapper.php.

References FileBackend\$name, $path, $res, as, DB_MASTER, DB_SLAVE, getDB(), getPathForSHA1(), list, and FileBackend\splitStoragePath().

Referenced by getBackendPath(), mungeOpPaths(), preloadCache(), translateArrayResults(), and translateSrcParams().

FileBackendDBRepoWrapper::getDB (   $index)
protected

Get a connection to the repo file registry DB.

Parameters
integer$index
Returns
DBConnRef

Definition at line 285 of file FileBackendDBRepoWrapper.php.

References $dbHandleFunc.

Referenced by getBackendPaths().

FileBackendDBRepoWrapper::getDirectoryList ( array  $params)

Definition at line 234 of file FileBackendDBRepoWrapper.php.

FileBackendDBRepoWrapper::getFeatures ( )

Definition at line 242 of file FileBackendDBRepoWrapper.php.

FileBackendDBRepoWrapper::getFileContentsMulti ( array  $params)

Definition at line 214 of file FileBackendDBRepoWrapper.php.

References translateArrayResults().

FileBackendDBRepoWrapper::getFileHttpUrl ( array  $params)

Definition at line 226 of file FileBackendDBRepoWrapper.php.

References translateSrcParams().

FileBackendDBRepoWrapper::getFileList ( array  $params)

Definition at line 238 of file FileBackendDBRepoWrapper.php.

FileBackendDBRepoWrapper::getFileProps ( array  $params)

Definition at line 198 of file FileBackendDBRepoWrapper.php.

References translateSrcParams().

FileBackendDBRepoWrapper::getFileSha1Base36 ( array  $params)

Definition at line 194 of file FileBackendDBRepoWrapper.php.

References translateSrcParams().

FileBackendDBRepoWrapper::getFileSize ( array  $params)

Definition at line 182 of file FileBackendDBRepoWrapper.php.

References translateSrcParams().

FileBackendDBRepoWrapper::getFileStat ( array  $params)

Definition at line 186 of file FileBackendDBRepoWrapper.php.

References translateSrcParams().

FileBackendDBRepoWrapper::getFileTimestamp ( array  $params)

Definition at line 178 of file FileBackendDBRepoWrapper.php.

References translateSrcParams().

FileBackendDBRepoWrapper::getFileXAttributes ( array  $params)

Definition at line 190 of file FileBackendDBRepoWrapper.php.

References translateSrcParams().

FileBackendDBRepoWrapper::getInternalBackend ( )

Get the underlying FileBackend that is being wrapped.

Returns
FileBackend

Definition at line 67 of file FileBackendDBRepoWrapper.php.

References $backend.

FileBackendDBRepoWrapper::getLocalCopyMulti ( array  $params)

Definition at line 222 of file FileBackendDBRepoWrapper.php.

References translateArrayResults().

FileBackendDBRepoWrapper::getLocalReferenceMulti ( array  $params)

Definition at line 218 of file FileBackendDBRepoWrapper.php.

References translateArrayResults().

FileBackendDBRepoWrapper::getPathForSHA1 (   $sha1)

Get the ultimate original storage path for a file.

Use this when putting a new file into the system

Parameters
string$sha1File SHA-1 base36
Returns
string

Definition at line 271 of file FileBackendDBRepoWrapper.php.

Referenced by getBackendPaths().

FileBackendDBRepoWrapper::getScopedLocksForOps ( array  $ops,
Status  $status 
)

Definition at line 259 of file FileBackendDBRepoWrapper.php.

FileBackendDBRepoWrapper::mungeOpPaths ( array  $ops)
protected

Translate legacy "title" source paths to their "sha1" counterparts.

This leaves destination paths alone since we don't want those to mutate

Parameters
array$ops
Returns
array

Definition at line 343 of file FileBackendDBRepoWrapper.php.

References as, getBackendPath(), and getBackendPaths().

Referenced by doOperationsInternal(), and doQuickOperationsInternal().

FileBackendDBRepoWrapper::preloadCache ( array  $paths)

Definition at line 250 of file FileBackendDBRepoWrapper.php.

References getBackendPaths().

FileBackendDBRepoWrapper::preloadFileStat ( array  $params)

Definition at line 255 of file FileBackendDBRepoWrapper.php.

References translateSrcParams().

FileBackendDBRepoWrapper::streamFile ( array  $params)
FileBackendDBRepoWrapper::translateArrayResults (   $function,
array  $params 
)
protected

Translates paths when the backend function returns results keyed by paths.

Parameters
string$function
array$params
Returns
array

Definition at line 320 of file FileBackendDBRepoWrapper.php.

References $path, as, and getBackendPaths().

Referenced by getFileContentsMulti(), getLocalCopyMulti(), and getLocalReferenceMulti().

FileBackendDBRepoWrapper::translateSrcParams (   $function,
array  $params 
)
protected

Translates paths found in the "src" or "srcs" keys of a params array.

Parameters
string$function
array$params

Definition at line 299 of file FileBackendDBRepoWrapper.php.

References getBackendPath(), and getBackendPaths().

Referenced by concatenate(), fileExists(), getFileHttpUrl(), getFileProps(), getFileSha1Base36(), getFileSize(), getFileStat(), getFileTimestamp(), getFileXAttributes(), preloadFileStat(), and streamFile().

Member Data Documentation

FileBackend FileBackendDBRepoWrapper::$backend
protected

Definition at line 42 of file FileBackendDBRepoWrapper.php.

Referenced by getInternalBackend().

Closure FileBackendDBRepoWrapper::$dbHandleFunc
protected

Definition at line 46 of file FileBackendDBRepoWrapper.php.

Referenced by getDB().

DBConnRef [] FileBackendDBRepoWrapper::$dbs
protected

Definition at line 50 of file FileBackendDBRepoWrapper.php.

string FileBackendDBRepoWrapper::$repoName
protected

Definition at line 44 of file FileBackendDBRepoWrapper.php.

ProcessCacheLRU FileBackendDBRepoWrapper::$resolvedPathCache
protected

Definition at line 48 of file FileBackendDBRepoWrapper.php.


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