MediaWiki  1.30.2
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)
 Create a new backend instance from configuration. 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...
 
 directoryExists (array $params)
 Check if a directory exists at a given storage path. More...
 
 fileExists (array $params)
 Check if a file exists at a storage path in the backend. More...
 
 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)
 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...
 
 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...
 
 getInternalBackend ()
 Get the underlying FileBackend that is being wrapped. 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...
 
 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...
 
 getPathForSHA1 ( $sha1)
 Get the ultimate original storage path for a file. More...
 
 getScopedLocksForOps (array $ops, StatusValue $status)
 Get an array of scoped locks needed for a batch of file operations. 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...
 
 streamFile (array $params)
 Stream the file at a storage path in the backend. More...
 
- Public Member Functions inherited from FileBackend
 clean (array $params)
 Delete a storage directory if it is empty. 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...
 
 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...
 
 getContainerStoragePath ( $container)
 Get the storage path for the given container for this backend. More...
 
 getDomainId ()
 Get the domain identifier used for this backend (possibly empty). More...
 
 getFileContents (array $params)
 Get the contents of 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...
 
 getLocalReference (array $params)
 Returns a file system file, identical to the file at a storage path. 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, StatusValue $status, $timeout=0)
 Lock the files at the given storage paths in the backend. 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 ()
 Alias to getDomainId() 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...
 
 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...
 
 setLogger (LoggerInterface $logger)
 
 store (array $params, array $opts=[])
 Performs a single store operation. 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
 getScopedPHPBehaviorForOps ()
 Enter file operation scope. More...
 
 newStatus ()
 Yields the result of the status wrapper callback on either: More...
 
 resetOutputBuffer ()
 
 resolveFSFileObjects (array $ops)
 Convert FSFile 'src' paths to string paths (with an 'srcRef' field set to the FSFile) More...
 
 scopedProfileSection ( $section)
 
 wrapStatus (StatusValue $sv)
 

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...
 
string $domainId
 Unique domain name. More...
 
FileJournal $fileJournal
 
LockManager $lockManager
 
LoggerInterface $logger
 
string $name
 Unique backend name. More...
 
callable $obResetFunc
 
string $parallelize
 When to do operations in parallel. More...
 
object string $profiler
 Class name or object With profileIn/profileOut methods. More...
 
string $readOnly
 Read-only explanation message. More...
 
callable $statusWrapper
 
callable $streamMimeFunc
 
string $tmpDirectory
 Temporary file directory. 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 latter 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 41 of file FileBackendDBRepoWrapper.php.

Constructor & Destructor Documentation

◆ __construct()

FileBackendDBRepoWrapper::__construct ( array  $config)

Create a new backend instance from configuration.

This should only be called from within FileBackendGroup.

Parameters
array$configParameters include:
  • name : The unique name of this backend. This should consist of alphanumberic, '-', and '_' characters. This name should not be changed after use (e.g. with journaling). Note that the name is not used in actual container names.
  • domainId : Prefix to container names that is unique to this backend. It should only consist of alphanumberic, '-', and '_' characters. This ID is what avoids collisions if multiple logical backends use the same storage system, so this should be set carefully.
  • lockManager : LockManager object to use for any file locking. If not provided, then no file locking will be enforced.
  • fileJournal : FileJournal object to use for logging changes to files. If not provided, then change journaling will be disabled.
  • readOnly : Write operations are disallowed if this is a non-empty string. It should be an explanation for the backend being read-only.
  • parallelize : When to do file operations in parallel (when possible). Allowed values are "implicit", "explicit" and "off".
  • concurrency : How many file operations can be done in parallel.
  • tmpDirectory : Directory to use for temporary files. If this is not set or null, then the backend will try to discover a usable temporary directory.
  • obResetFunc : alternative callback to clear the output buffer
  • streamMimeFunc : alternative method to determine the content type from the path
  • logger : Optional PSR logger object.
  • profiler : Optional class name or object With profileIn/profileOut methods.
Exceptions
InvalidArgumentException

Reimplemented from FileBackend.

Definition at line 53 of file FileBackendDBRepoWrapper.php.

References $backend, FileBackend\getName(), and FileBackend\getWikiId().

Member Function Documentation

◆ clearCache()

FileBackendDBRepoWrapper::clearCache ( array  $paths = null)

Invalidate any in-process file stat and property cache.

If $paths is given, then only the cache for those files will be cleared.

See also
FileBackend::getFileStat()
Parameters
array$pathsStorage paths (optional)

Reimplemented from FileBackend.

Definition at line 249 of file FileBackendDBRepoWrapper.php.

◆ concatenate()

FileBackendDBRepoWrapper::concatenate ( array  $params)

Concatenate a list of storage files into a single file system file.

The target path should refer to a file that is already locked or otherwise safe from modification from other processes. Normally, the file will be a new temp file, which should be adequate.

Parameters
array$paramsOperation parameters, include:
  • srcs : ordered source storage paths (e.g. chunk1, chunk2, ...)
  • dst : file system path to 0-byte temp file
  • parallelize : try to do operations in parallel when possible
Returns
StatusValue

Reimplemented from FileBackend.

Definition at line 173 of file FileBackendDBRepoWrapper.php.

References $params, and translateSrcParams().

◆ directoryExists()

FileBackendDBRepoWrapper::directoryExists ( array  $params)

Check if a directory exists at a given storage path.

Backends using key/value stores will check if the path is a virtual directory, meaning there are files under the given directory.

Storage backends with eventual consistency might return stale data.

Parameters
array$paramsParameters include:
  • dir : storage directory
Returns
bool|null Returns null on failure
Since
1.20

Reimplemented from FileBackend.

Definition at line 233 of file FileBackendDBRepoWrapper.php.

References $params.

◆ doClean()

FileBackendDBRepoWrapper::doClean ( array  $params)
protected
See also
FileBackend::clean()
Parameters
array$params

Reimplemented from FileBackend.

Definition at line 169 of file FileBackendDBRepoWrapper.php.

References $params.

◆ doOperationsInternal()

FileBackendDBRepoWrapper::doOperationsInternal ( array  $ops,
array  $opts 
)
protected
See also
FileBackend::doOperations()
Parameters
array$ops
array$opts

Reimplemented from FileBackend.

Definition at line 149 of file FileBackendDBRepoWrapper.php.

References mungeOpPaths().

◆ doPrepare()

FileBackendDBRepoWrapper::doPrepare ( array  $params)
protected
See also
FileBackend::prepare()
Parameters
array$params

Reimplemented from FileBackend.

Definition at line 157 of file FileBackendDBRepoWrapper.php.

References $params.

◆ doPublish()

FileBackendDBRepoWrapper::doPublish ( array  $params)
protected
See also
FileBackend::publish()
Parameters
array$params

Reimplemented from FileBackend.

Definition at line 165 of file FileBackendDBRepoWrapper.php.

References $params.

◆ doQuickOperationsInternal()

FileBackendDBRepoWrapper::doQuickOperationsInternal ( array  $ops)
protected
See also
FileBackend::doQuickOperations()
Parameters
array$ops
Since
1.20

Reimplemented from FileBackend.

Definition at line 153 of file FileBackendDBRepoWrapper.php.

References mungeOpPaths().

◆ doSecure()

FileBackendDBRepoWrapper::doSecure ( array  $params)
protected
See also
FileBackend::secure()
Parameters
array$params

Reimplemented from FileBackend.

Definition at line 161 of file FileBackendDBRepoWrapper.php.

References $params.

◆ fileExists()

FileBackendDBRepoWrapper::fileExists ( array  $params)

Check if a file exists at a storage path in the backend.

This returns false if only a directory exists at the path.

Parameters
array$paramsParameters include:
  • src : source storage path
  • latest : use the latest available data
Returns
bool|null Returns null on failure

Reimplemented from FileBackend.

Definition at line 177 of file FileBackendDBRepoWrapper.php.

References $params, and translateSrcParams().

◆ getBackendPath()

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 84 of file FileBackendDBRepoWrapper.php.

References $path, and getBackendPaths().

Referenced by mungeOpPaths(), and translateSrcParams().

◆ getBackendPaths()

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 99 of file FileBackendDBRepoWrapper.php.

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

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

◆ getDB()

FileBackendDBRepoWrapper::getDB (   $index)
protected

Get a connection to the repo file registry DB.

Parameters
int$index
Returns
DBConnRef

Definition at line 288 of file FileBackendDBRepoWrapper.php.

References $dbHandleFunc.

Referenced by getBackendPaths().

◆ getDirectoryList()

FileBackendDBRepoWrapper::getDirectoryList ( array  $params)

Get an iterator to list all directories under a storage directory.

If the directory is of the form "mwstore://backend/container", then all directories in the container will be listed. If the directory is of form "mwstore://backend/container/dir", then all directories directly under that directory will be listed. Results will be storage directories relative to the given directory.

Storage backends with eventual consistency might return stale data.

Failures during iteration can result in FileBackendError exceptions (since 1.22).

Parameters
array$paramsParameters include:
  • dir : storage directory
  • topOnly : only return direct child dirs of the directory
Returns
Traversable|array|null Returns null on failure
Since
1.20

Reimplemented from FileBackend.

Definition at line 237 of file FileBackendDBRepoWrapper.php.

References $params.

◆ getFeatures()

FileBackendDBRepoWrapper::getFeatures ( )

Get the a bitfield of extra features supported by the backend medium.

Returns
int Bitfield of FileBackend::ATTR_* flags
Since
1.23

Reimplemented from FileBackend.

Definition at line 245 of file FileBackendDBRepoWrapper.php.

◆ getFileContentsMulti()

FileBackendDBRepoWrapper::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).

The map keys (paths) are in the same order as the provided list of paths.

See also
FileBackend::getFileContents()
Parameters
array$paramsParameters include:
  • srcs : list of source storage paths
  • latest : use the latest available data
  • parallelize : try to do operations in parallel when possible
Returns
array Map of (path name => string or false on failure)
Since
1.20

Reimplemented from FileBackend.

Definition at line 217 of file FileBackendDBRepoWrapper.php.

References $params, and translateArrayResults().

◆ getFileHttpUrl()

FileBackendDBRepoWrapper::getFileHttpUrl ( array  $params)

Return an HTTP URL to a given file that requires no authentication to use.

The URL may be pre-authenticated (via some token in the URL) and temporary. This will return null if the backend cannot make an HTTP URL for the file.

This is useful for key/value stores when using scripts that seek around large files and those scripts (and the backend) support HTTP Range headers. Otherwise, one would need to use getLocalReference(), which involves loading the entire file on to local disk.

Parameters
array$paramsParameters include:
  • src : source storage path
  • ttl : lifetime (seconds) if pre-authenticated; default is 1 day
Returns
string|null
Since
1.21

Reimplemented from FileBackend.

Definition at line 229 of file FileBackendDBRepoWrapper.php.

References $params, and translateSrcParams().

◆ getFileList()

FileBackendDBRepoWrapper::getFileList ( array  $params)

Get an iterator to list all stored files under a storage directory.

If the directory is of the form "mwstore://backend/container", then all files in the container will be listed. If the directory is of form "mwstore://backend/container/dir", then all files under that directory will be listed. Results will be storage paths relative to the given directory.

Storage backends with eventual consistency might return stale data.

Failures during iteration can result in FileBackendError exceptions (since 1.22).

Parameters
array$paramsParameters include:
  • dir : storage directory
  • topOnly : only return direct child files of the directory (since 1.20)
  • adviseStat : set to true if stat requests will be made on the files (since 1.22)
Returns
Traversable|array|null Returns null on failure

Reimplemented from FileBackend.

Definition at line 241 of file FileBackendDBRepoWrapper.php.

References $params.

◆ getFileProps()

FileBackendDBRepoWrapper::getFileProps ( array  $params)

Get the properties of the file at a storage path in the backend.

This gives the result of FSFile::getProps() on a local copy of the file.

Parameters
array$paramsParameters include:
  • src : source storage path
  • latest : use the latest available data
Returns
array Returns FSFile::placeholderProps() on failure

Reimplemented from FileBackend.

Definition at line 201 of file FileBackendDBRepoWrapper.php.

References $params, and translateSrcParams().

◆ getFileSha1Base36()

FileBackendDBRepoWrapper::getFileSha1Base36 ( array  $params)

Get a SHA-1 hash of the file at a storage path in the backend.

Parameters
array$paramsParameters include:
  • src : source storage path
  • latest : use the latest available data
Returns
string|bool Hash string or false on failure

Reimplemented from FileBackend.

Definition at line 197 of file FileBackendDBRepoWrapper.php.

References $params, and translateSrcParams().

◆ getFileSize()

FileBackendDBRepoWrapper::getFileSize ( array  $params)

Get the size (bytes) of a file at a storage path in the backend.

Parameters
array$paramsParameters include:
  • src : source storage path
  • latest : use the latest available data
Returns
int|bool Returns false on failure

Reimplemented from FileBackend.

Definition at line 185 of file FileBackendDBRepoWrapper.php.

References $params, and translateSrcParams().

◆ getFileStat()

FileBackendDBRepoWrapper::getFileStat ( array  $params)

Get quick information about a file at a storage path in the backend.

If the file does not exist, then this returns false. Otherwise, the result is an associative array that includes:

  • mtime : the last-modified timestamp (TS_MW)
  • size : the file size (bytes) Additional values may be included for internal use only.
Parameters
array$paramsParameters include:
  • src : source storage path
  • latest : use the latest available data
Returns
array|bool|null Returns null on failure

Reimplemented from FileBackend.

Definition at line 189 of file FileBackendDBRepoWrapper.php.

References $params, and translateSrcParams().

◆ getFileTimestamp()

FileBackendDBRepoWrapper::getFileTimestamp ( array  $params)

Get the last-modified timestamp of the file at a storage path.

Parameters
array$paramsParameters include:
  • src : source storage path
  • latest : use the latest available data
Returns
string|bool TS_MW timestamp or false on failure

Reimplemented from FileBackend.

Definition at line 181 of file FileBackendDBRepoWrapper.php.

References $params, and translateSrcParams().

◆ getFileXAttributes()

FileBackendDBRepoWrapper::getFileXAttributes ( array  $params)

Get metadata about a file at a storage path in the backend.

If the file does not exist, then this returns false. Otherwise, the result is an associative array that includes:

  • headers : map of HTTP headers used for GET/HEAD requests (name => value)
  • metadata : map of file metadata (name => value) Metadata keys and headers names will be returned in all lower-case. Additional values may be included for internal use only.

Use FileBackend::hasFeatures() to check how well this is supported.

Parameters
array$params$params include:
  • src : source storage path
  • latest : use the latest available data
Returns
array|bool Returns false on failure
Since
1.23

Reimplemented from FileBackend.

Definition at line 193 of file FileBackendDBRepoWrapper.php.

References $params, and translateSrcParams().

◆ getInternalBackend()

FileBackendDBRepoWrapper::getInternalBackend ( )

Get the underlying FileBackend that is being wrapped.

Returns
FileBackend

Definition at line 70 of file FileBackendDBRepoWrapper.php.

References $backend.

◆ getLocalCopyMulti()

FileBackendDBRepoWrapper::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).

The map keys (paths) are in the same order as the provided list of paths.

See also
FileBackend::getLocalCopy()
Parameters
array$paramsParameters include:
  • srcs : list of source storage paths
  • latest : use the latest available data
  • parallelize : try to do operations in parallel when possible
Returns
array Map of (path name => TempFSFile or null on failure)
Since
1.20

Reimplemented from FileBackend.

Definition at line 225 of file FileBackendDBRepoWrapper.php.

References $params, and translateArrayResults().

◆ getLocalReferenceMulti()

FileBackendDBRepoWrapper::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).

The map keys (paths) are in the same order as the provided list of paths.

See also
FileBackend::getLocalReference()
Parameters
array$paramsParameters include:
  • srcs : list of source storage paths
  • latest : use the latest available data
  • parallelize : try to do operations in parallel when possible
Returns
array Map of (path name => FSFile or null on failure)
Since
1.20

Reimplemented from FileBackend.

Definition at line 221 of file FileBackendDBRepoWrapper.php.

References $params, and translateArrayResults().

◆ getPathForSHA1()

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 274 of file FileBackendDBRepoWrapper.php.

Referenced by getBackendPaths().

◆ getScopedLocksForOps()

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

Get an array of scoped locks needed for a batch of file operations.

Normally, FileBackend::doOperations() handles locking, unless the 'nonLocking' param is passed in. This function is useful if you want the files to be locked for a broader scope than just when the files are changing. For example, if you need to update DB metadata, you may want to keep the files locked until finished.

See also
FileBackend::doOperations()
Parameters
array$opsList of file operations to FileBackend::doOperations()
StatusValue$statusStatusValue to update on lock/unlock
Returns
ScopedLock|null
Since
1.20

Reimplemented from FileBackend.

Definition at line 262 of file FileBackendDBRepoWrapper.php.

◆ mungeOpPaths()

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 347 of file FileBackendDBRepoWrapper.php.

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

Referenced by doOperationsInternal(), and doQuickOperationsInternal().

◆ preloadCache()

FileBackendDBRepoWrapper::preloadCache ( array  $paths)

Preload persistent file stat cache and property cache into in-process cache.

This should be used when stat calls will be made on a known list of a many files.

See also
FileBackend::getFileStat()
Parameters
array$pathsStorage paths

Reimplemented from FileBackend.

Definition at line 253 of file FileBackendDBRepoWrapper.php.

References getBackendPaths().

◆ preloadFileStat()

FileBackendDBRepoWrapper::preloadFileStat ( array  $params)

Preload file stat information (concurrently if possible) into in-process cache.

This should be used when stat calls will be made on a known list of a many files. This does not make use of the persistent file stat cache.

See also
FileBackend::getFileStat()
Parameters
array$paramsParameters include:
  • srcs : list of source storage paths
  • latest : use the latest available data
Returns
bool All requests proceeded without I/O errors (since 1.24)
Since
1.23

Reimplemented from FileBackend.

Definition at line 258 of file FileBackendDBRepoWrapper.php.

References $params, and translateSrcParams().

◆ streamFile()

FileBackendDBRepoWrapper::streamFile ( array  $params)

Stream the file at a storage path in the backend.

If the file does not exists, an HTTP 404 error will be given. Appropriate HTTP headers (Status, Content-Type, Content-Length) will be sent if streaming began, while none will be sent otherwise. Implementations should flush the output buffer before sending data.

Parameters
array$paramsParameters include:
  • src : source storage path
  • headers : list of additional HTTP headers to send if the file exists
  • options : HTTP request header map with lower case keys (since 1.28). Supports: range : format is "bytes=(\\d*-\\d*)" if-modified-since : format is an HTTP date
  • headless : only include the body (and headers from "headers") (since 1.28)
  • latest : use the latest available data
  • allowOB : preserve any output buffers (since 1.28)
Returns
StatusValue

Reimplemented from FileBackend.

Definition at line 205 of file FileBackendDBRepoWrapper.php.

References $params, $type, StreamFile\contentTypeFromPath(), and translateSrcParams().

◆ translateArrayResults()

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 324 of file FileBackendDBRepoWrapper.php.

References $params, $path, as, and getBackendPaths().

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

◆ translateSrcParams()

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

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

Parameters
string$function
array$params
Returns
mixed

Definition at line 303 of file FileBackendDBRepoWrapper.php.

References $params, getBackendPath(), and getBackendPaths().

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

Member Data Documentation

◆ $backend

FileBackend FileBackendDBRepoWrapper::$backend
protected

Definition at line 43 of file FileBackendDBRepoWrapper.php.

Referenced by __construct(), and getInternalBackend().

◆ $dbHandleFunc

Closure FileBackendDBRepoWrapper::$dbHandleFunc
protected

Definition at line 47 of file FileBackendDBRepoWrapper.php.

Referenced by getDB().

◆ $dbs

DBConnRef [] FileBackendDBRepoWrapper::$dbs
protected

Definition at line 51 of file FileBackendDBRepoWrapper.php.

◆ $repoName

string FileBackendDBRepoWrapper::$repoName
protected

Definition at line 45 of file FileBackendDBRepoWrapper.php.

◆ $resolvedPathCache

ProcessCacheLRU FileBackendDBRepoWrapper::$resolvedPathCache
protected

Definition at line 49 of file FileBackendDBRepoWrapper.php.


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