diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2013-09-30 00:12:10 -0700 |
---|---|---|
committer | Aaron Schulz <aschulz@wikimedia.org> | 2014-01-08 13:22:11 -0800 |
commit | ac14c1c8a65d154f7a9bc47d1b51f6db67188f86 (patch) | |
tree | d581f21014ede6fcd8b53a0a9489adef76b5cabf /includes/filebackend/FileBackend.php | |
parent | b8ef0a54700fca3fb6d119cedb657c28df926906 (diff) | |
download | mediawikicore-ac14c1c8a65d154f7a9bc47d1b51f6db67188f86.tar.gz mediawikicore-ac14c1c8a65d154f7a9bc47d1b51f6db67188f86.zip |
filebackend: Added supported for retrieving file metadata/headers
* This can be useful for carrying over metadata when copying files around
* Also fixed a bug in sanitizeHdrs() for Swift (broken content-disposition)
Change-Id: I4534e9acac2b306086797b3677f85c05b98e39fc
Diffstat (limited to 'includes/filebackend/FileBackend.php')
-rw-r--r-- | includes/filebackend/FileBackend.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/includes/filebackend/FileBackend.php b/includes/filebackend/FileBackend.php index bb21f1b5e492..f5d63b9df78e 100644 --- a/includes/filebackend/FileBackend.php +++ b/includes/filebackend/FileBackend.php @@ -104,6 +104,10 @@ abstract class FileBackend { /** @var FileJournal */ protected $fileJournal; + /** Flags for supported features */ + const ATTR_HEADERS = 1; + const ATTR_METADATA = 2; + /** * Create a new backend instance from configuration. * This should only be called from within FileBackendGroup. @@ -201,6 +205,27 @@ abstract class FileBackend { } /** + * Get the a bitfield of extra features supported by the backend medium + * + * @return integer Bitfield of FileBackend::ATTR_* flags + * @since 1.23 + */ + public function getFeatures() { + return 0; + } + + /** + * Check if the backend medium supports a field of extra features + * + * @return integer Bitfield of FileBackend::ATTR_* flags + * @return bool + * @since 1.23 + */ + final public function hasFeatures( $bitfield ) { + return ( $this->getFeatures() & $bitfield ) === $bitfield; + } + + /** * This is the main entry point into the backend for write operations. * Callers supply an ordered list of operations to perform as a transaction. * Files will be locked, the stat cache cleared, and then the operations attempted. @@ -902,6 +927,26 @@ abstract class FileBackend { abstract public function getFileContentsMulti( 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. + * + * @param array $params + * $params include: + * - src : source storage path + * - latest : use the latest available data + * @return Array|bool Returns false on failure + * @since 1.23 + */ + abstract public function getFileXAttributes( array $params ); + + /** * Get the size (bytes) of a file at a storage path in the backend. * * @param array $params Parameters include: |