From 92408acbfb72380a0bfece19b0869f6392d646cb Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 29 Jan 2012 22:22:28 +0000 Subject: [PATCH] Renamed FileBackend to FileBackendStore and ugly FileBackendBase to FileBackend. Callers doing things like FileBackend::extensionFromPath() are now more proper. --- includes/AutoLoader.php | 4 +- includes/filerepo/FileRepo.php | 6 +- includes/filerepo/backend/FSFileBackend.php | 36 +++--- includes/filerepo/backend/FileBackend.php | 104 +++++++++--------- .../filerepo/backend/FileBackendGroup.php | 4 +- .../backend/FileBackendMultiWrite.php | 54 ++++----- includes/filerepo/backend/FileOp.php | 16 +-- .../filerepo/backend/SwiftFileBackend.php | 37 +++---- 8 files changed, 130 insertions(+), 131 deletions(-) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 6c3b233afc..d9dcacf652 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -494,10 +494,10 @@ $wgAutoloadLocalClasses = array( # includes/filerepo/backend 'FileBackendGroup' => 'includes/filerepo/backend/FileBackendGroup.php', - 'FileBackendBase' => 'includes/filerepo/backend/FileBackend.php', 'FileBackend' => 'includes/filerepo/backend/FileBackend.php', + 'FileBackendStore' => 'includes/filerepo/backend/FileBackend.php', 'FileBackendMultiWrite' => 'includes/filerepo/backend/FileBackendMultiWrite.php', - 'FileBackendShardListIterator' => 'includes/filerepo/backend/FileBackend.php', + 'FileBackendStoreShardListIterator' => 'includes/filerepo/backend/FileBackend.php', 'FSFileBackend' => 'includes/filerepo/backend/FSFileBackend.php', 'FSFileBackendFileList' => 'includes/filerepo/backend/FSFileBackend.php', 'SwiftFileBackend' => 'includes/filerepo/backend/SwiftFileBackend.php', diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index c9e5e7ff66..c4fee087d3 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -19,7 +19,7 @@ class FileRepo { const OVERWRITE_SAME = 4; const SKIP_LOCKING = 8; - /** @var FileBackendBase */ + /** @var FileBackend */ protected $backend; /** @var Array Map of zones to config */ protected $zones = array(); @@ -51,7 +51,7 @@ class FileRepo { // Required settings $this->name = $info['name']; - if ( $info['backend'] instanceof FileBackendBase ) { + if ( $info['backend'] instanceof FileBackend ) { $this->backend = $info['backend']; // useful for testing } else { $this->backend = FileBackendGroup::singleton()->get( $info['backend'] ); @@ -105,7 +105,7 @@ class FileRepo { /** * Get the file backend instance * - * @return FileBackendBase + * @return FileBackend */ public function getBackend() { return $this->backend; diff --git a/includes/filerepo/backend/FSFileBackend.php b/includes/filerepo/backend/FSFileBackend.php index a4ad3d4bbe..f6748c81b0 100644 --- a/includes/filerepo/backend/FSFileBackend.php +++ b/includes/filerepo/backend/FSFileBackend.php @@ -21,7 +21,7 @@ * @ingroup FileBackend * @since 1.19 */ -class FSFileBackend extends FileBackend { +class FSFileBackend extends FileBackendStore { protected $basePath; // string; directory holding the container directories /** @var Array Map of container names to root paths */ protected $containerPaths = array(); // for custom container paths @@ -30,7 +30,7 @@ class FSFileBackend extends FileBackend { protected $hadWarningErrors = array(); /** - * @see FileBackend::__construct() + * @see FileBackendStore::__construct() * Additional $config params include: * basePath : File system directory that holds containers. * containerPaths : Map of container names to custom file system directories. @@ -58,7 +58,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::resolveContainerName() + * @see FileBackendStore::resolveContainerName() */ protected function resolveContainerName( $container ) { if ( $container !== '.' ) { @@ -68,7 +68,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::resolveContainerPath() + * @see FileBackendStore::resolveContainerPath() */ protected function resolveContainerPath( $container, $relStoragePath ) { if ( isset( $this->containerPaths[$container] ) || isset( $this->basePath ) ) { @@ -114,7 +114,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::isPathUsableInternal() + * @see FileBackendStore::isPathUsableInternal() */ public function isPathUsableInternal( $storagePath ) { $fsPath = $this->resolveToFSPath( $storagePath ); @@ -135,7 +135,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::doStoreInternal() + * @see FileBackendStore::doStoreInternal() */ protected function doStoreInternal( array $params ) { $status = Status::newGood(); @@ -175,7 +175,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::doCopyInternal() + * @see FileBackendStore::doCopyInternal() */ protected function doCopyInternal( array $params ) { $status = Status::newGood(); @@ -221,7 +221,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::doMoveInternal() + * @see FileBackendStore::doMoveInternal() */ protected function doMoveInternal( array $params ) { $status = Status::newGood(); @@ -269,7 +269,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::doDeleteInternal() + * @see FileBackendStore::doDeleteInternal() */ protected function doDeleteInternal( array $params ) { $status = Status::newGood(); @@ -299,7 +299,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::doCreateInternal() + * @see FileBackendStore::doCreateInternal() */ protected function doCreateInternal( array $params ) { $status = Status::newGood(); @@ -339,7 +339,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::doPrepareInternal() + * @see FileBackendStore::doPrepareInternal() */ protected function doPrepareInternal( $fullCont, $dirRel, array $params ) { $status = Status::newGood(); @@ -357,7 +357,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::doSecureInternal() + * @see FileBackendStore::doSecureInternal() */ protected function doSecureInternal( $fullCont, $dirRel, array $params ) { $status = Status::newGood(); @@ -391,7 +391,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::doCleanInternal() + * @see FileBackendStore::doCleanInternal() */ protected function doCleanInternal( $fullCont, $dirRel, array $params ) { $status = Status::newGood(); @@ -407,7 +407,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::doFileExists() + * @see FileBackendStore::doFileExists() */ protected function doGetFileStat( array $params ) { $source = $this->resolveToFSPath( $params['src'] ); @@ -432,14 +432,14 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::doClearCache() + * @see FileBackendStore::doClearCache() */ protected function doClearCache( array $paths = null ) { clearstatcache(); // clear the PHP file stat cache } /** - * @see FileBackend::getFileListInternal() + * @see FileBackendStore::getFileListInternal() */ public function getFileListInternal( $fullCont, $dirRel, array $params ) { list( $b, $shortCont, $r ) = FileBackend::splitStoragePath( $params['dir'] ); @@ -461,7 +461,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::getLocalReference() + * @see FileBackendStore::getLocalReference() */ public function getLocalReference( array $params ) { $source = $this->resolveToFSPath( $params['src'] ); @@ -472,7 +472,7 @@ class FSFileBackend extends FileBackend { } /** - * @see FileBackend::getLocalCopy() + * @see FileBackendStore::getLocalCopy() */ public function getLocalCopy( array $params ) { $source = $this->resolveToFSPath( $params['src'] ); diff --git a/includes/filerepo/backend/FileBackend.php b/includes/filerepo/backend/FileBackend.php index 971bb76968..fbae494159 100644 --- a/includes/filerepo/backend/FileBackend.php +++ b/includes/filerepo/backend/FileBackend.php @@ -29,7 +29,7 @@ * @ingroup FileBackend * @since 1.19 */ -abstract class FileBackendBase { +abstract class FileBackend { protected $name; // string; unique backend name protected $wikiId; // string; unique wiki name protected $readOnly; // string; read-only explanation message @@ -170,7 +170,7 @@ abstract class FileBackendBase { } /** - * @see FileBackendBase::doOperations() + * @see FileBackend::doOperations() */ abstract protected function doOperationsInternal( array $ops, array $opts ); @@ -179,7 +179,7 @@ abstract class FileBackendBase { * If you are doing a batch of operations that should either * all succeed or all fail, then use that function instead. * - * @see FileBackendBase::doOperations() + * @see FileBackend::doOperations() * * @param $op Array Operation * @param $opts Array Operation options @@ -193,7 +193,7 @@ abstract class FileBackendBase { * Performs a single create operation. * This sets $params['op'] to 'create' and passes it to doOperation(). * - * @see FileBackendBase::doOperation() + * @see FileBackend::doOperation() * * @param $params Array Operation parameters * @param $opts Array Operation options @@ -208,7 +208,7 @@ abstract class FileBackendBase { * Performs a single store operation. * This sets $params['op'] to 'store' and passes it to doOperation(). * - * @see FileBackendBase::doOperation() + * @see FileBackend::doOperation() * * @param $params Array Operation parameters * @param $opts Array Operation options @@ -223,7 +223,7 @@ abstract class FileBackendBase { * Performs a single copy operation. * This sets $params['op'] to 'copy' and passes it to doOperation(). * - * @see FileBackendBase::doOperation() + * @see FileBackend::doOperation() * * @param $params Array Operation parameters * @param $opts Array Operation options @@ -238,7 +238,7 @@ abstract class FileBackendBase { * Performs a single move operation. * This sets $params['op'] to 'move' and passes it to doOperation(). * - * @see FileBackendBase::doOperation() + * @see FileBackend::doOperation() * * @param $params Array Operation parameters * @param $opts Array Operation options @@ -253,7 +253,7 @@ abstract class FileBackendBase { * Performs a single delete operation. * This sets $params['op'] to 'delete' and passes it to doOperation(). * - * @see FileBackendBase::doOperation() + * @see FileBackend::doOperation() * * @param $params Array Operation parameters * @param $opts Array Operation options @@ -297,7 +297,7 @@ abstract class FileBackendBase { } /** - * @see FileBackendBase::prepare() + * @see FileBackend::prepare() */ abstract protected function doPrepare( array $params ); @@ -328,7 +328,7 @@ abstract class FileBackendBase { } /** - * @see FileBackendBase::secure() + * @see FileBackend::secure() */ abstract protected function doSecure( array $params ); @@ -351,7 +351,7 @@ abstract class FileBackendBase { } /** - * @see FileBackendBase::clean() + * @see FileBackend::clean() */ abstract protected function doClean( array $params ); @@ -681,14 +681,14 @@ abstract class FileBackendBase { * This class defines the methods as abstract that subclasses must implement. * Outside callers should *not* use functions with "Internal" in the name. * - * The FileBackendBase operations are implemented using basic functions + * The FileBackend operations are implemented using basic functions * such as storeInternal(), copyInternal(), deleteInternal() and the like. * This class is also responsible for path resolution and sanitization. * * @ingroup FileBackend * @since 1.19 */ -abstract class FileBackend extends FileBackendBase { +abstract class FileBackendStore extends FileBackend { /** @var Array Map of paths to small (RAM/disk) cache items */ protected $cache = array(); // (storage path => key => value) protected $maxCacheSize = 100; // integer; max paths with entries @@ -747,7 +747,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::createInternal() + * @see FileBackendStore::createInternal() */ abstract protected function doCreateInternal( array $params ); @@ -776,7 +776,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::storeInternal() + * @see FileBackendStore::storeInternal() */ abstract protected function doStoreInternal( array $params ); @@ -801,7 +801,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::copyInternal() + * @see FileBackendStore::copyInternal() */ abstract protected function doCopyInternal( array $params ); @@ -825,7 +825,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::deleteInternal() + * @see FileBackendStore::deleteInternal() */ abstract protected function doDeleteInternal( array $params ); @@ -850,7 +850,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::moveInternal() + * @see FileBackendStore::moveInternal() */ protected function doMoveInternal( array $params ) { // Copy source to dest @@ -864,7 +864,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::concatenate() + * @see FileBackend::concatenate() */ final public function concatenate( array $params ) { wfProfileIn( __METHOD__ ); @@ -882,7 +882,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::concatenate() + * @see FileBackendStore::concatenate() */ protected function doConcatenate( array $params ) { $status = Status::newGood(); @@ -937,7 +937,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::doPrepare() + * @see FileBackend::doPrepare() */ final protected function doPrepare( array $params ) { wfProfileIn( __METHOD__ ); @@ -965,14 +965,14 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::doPrepare() + * @see FileBackendStore::doPrepare() */ protected function doPrepareInternal( $container, $dir, array $params ) { return Status::newGood(); } /** - * @see FileBackendBase::doSecure() + * @see FileBackend::doSecure() */ final protected function doSecure( array $params ) { wfProfileIn( __METHOD__ ); @@ -1000,14 +1000,14 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::doSecure() + * @see FileBackendStore::doSecure() */ protected function doSecureInternal( $container, $dir, array $params ) { return Status::newGood(); } /** - * @see FileBackendBase::doClean() + * @see FileBackend::doClean() */ final protected function doClean( array $params ) { wfProfileIn( __METHOD__ ); @@ -1043,14 +1043,14 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::doClean() + * @see FileBackendStore::doClean() */ protected function doCleanInternal( $container, $dir, array $params ) { return Status::newGood(); } /** - * @see FileBackendBase::fileExists() + * @see FileBackend::fileExists() */ final public function fileExists( array $params ) { wfProfileIn( __METHOD__ ); @@ -1060,7 +1060,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::getFileTimestamp() + * @see FileBackend::getFileTimestamp() */ final public function getFileTimestamp( array $params ) { wfProfileIn( __METHOD__ ); @@ -1070,7 +1070,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::getFileSize() + * @see FileBackend::getFileSize() */ final public function getFileSize( array $params ) { wfProfileIn( __METHOD__ ); @@ -1080,7 +1080,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::getFileStat() + * @see FileBackend::getFileStat() */ final public function getFileStat( array $params ) { wfProfileIn( __METHOD__ ); @@ -1108,12 +1108,12 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::getFileStat() + * @see FileBackendStore::getFileStat() */ abstract protected function doGetFileStat( array $params ); /** - * @see FileBackendBase::getFileContents() + * @see FileBackend::getFileContents() */ public function getFileContents( array $params ) { wfProfileIn( __METHOD__ ); @@ -1130,7 +1130,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::getFileSha1Base36() + * @see FileBackend::getFileSha1Base36() */ final public function getFileSha1Base36( array $params ) { wfProfileIn( __METHOD__ ); @@ -1149,7 +1149,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::getFileSha1Base36() + * @see FileBackendStore::getFileSha1Base36() */ protected function doGetFileSha1Base36( array $params ) { $fsFile = $this->getLocalReference( $params ); @@ -1161,7 +1161,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::getFileProps() + * @see FileBackend::getFileProps() */ final public function getFileProps( array $params ) { wfProfileIn( __METHOD__ ); @@ -1172,7 +1172,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::getLocalReference() + * @see FileBackend::getLocalReference() */ public function getLocalReference( array $params ) { wfProfileIn( __METHOD__ ); @@ -1191,7 +1191,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::streamFile() + * @see FileBackend::streamFile() */ final public function streamFile( array $params ) { wfProfileIn( __METHOD__ ); @@ -1218,7 +1218,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackend::streamFile() + * @see FileBackendStore::streamFile() */ protected function doStreamFile( array $params ) { $status = Status::newGood(); @@ -1234,7 +1234,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::getFileList() + * @see FileBackend::getFileList() */ final public function getFileList( array $params ) { list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] ); @@ -1248,7 +1248,7 @@ abstract class FileBackend extends FileBackendBase { wfDebug( __METHOD__ . ": iterating over all container shards.\n" ); // File listing spans multiple containers/shards list( $b, $shortCont, $r ) = self::splitStoragePath( $params['dir'] ); - return new FileBackendShardListIterator( $this, + return new FileBackendStoreShardListIterator( $this, $fullCont, $dir, $this->getContainerSuffixes( $shortCont ), $params ); } } @@ -1256,7 +1256,7 @@ abstract class FileBackend extends FileBackendBase { /** * Do not call this function from places outside FileBackend * - * @see FileBackend::getFileList() + * @see FileBackendStore::getFileList() * * @param $container string Resolved container name * @param $dir string Resolved path relative to container @@ -1314,7 +1314,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::doOperationsInternal() + * @see FileBackend::doOperationsInternal() */ protected function doOperationsInternal( array $ops, array $opts ) { wfProfileIn( __METHOD__ ); @@ -1359,7 +1359,7 @@ abstract class FileBackend extends FileBackendBase { } /** - * @see FileBackendBase::clearCache() + * @see FileBackend::clearCache() */ final public function clearCache( array $paths = null ) { if ( is_array( $paths ) ) { @@ -1381,7 +1381,7 @@ abstract class FileBackend extends FileBackendBase { /** * Clears any additional stat caches for storage paths * - * @see FileBackendBase::clearCache() + * @see FileBackend::clearCache() * * @param $paths Array Storage paths (optional) * @return void @@ -1469,7 +1469,7 @@ abstract class FileBackend extends FileBackendBase { * Like resolveStoragePath() except null values are returned if * the container is sharded and the shard could not be determined. * - * @see FileBackend::resolveStoragePath() + * @see FileBackendStore::resolveStoragePath() * * @param $storagePath string * @return Array (container, path) or (null, null) if invalid @@ -1587,13 +1587,13 @@ abstract class FileBackend extends FileBackendBase { } /** - * FileBackend helper function to handle file listings that span container shards. - * Do not use this class from places outside of FileBackend. + * FileBackendStore helper function to handle file listings that span container shards. + * Do not use this class from places outside of FileBackendStore. * - * @ingroup FileBackend + * @ingroup FileBackendStore */ -class FileBackendShardListIterator implements Iterator { - /* @var FileBackend */ +class FileBackendStoreShardListIterator implements Iterator { + /* @var FileBackendStore */ protected $backend; /* @var Array */ protected $params; @@ -1608,14 +1608,14 @@ class FileBackendShardListIterator implements Iterator { protected $pos = 0; // integer /** - * @param $backend FileBackend + * @param $backend FileBackendStore * @param $container string Full storage container name * @param $dir string Storage directory relative to container * @param $suffixes Array List of container shard suffixes * @param $params Array */ public function __construct( - FileBackend $backend, $container, $dir, array $suffixes, array $params + FileBackendStore $backend, $container, $dir, array $suffixes, array $params ) { $this->backend = $backend; $this->container = $container; diff --git a/includes/filerepo/backend/FileBackendGroup.php b/includes/filerepo/backend/FileBackendGroup.php index d3deec3168..73815cfbdd 100644 --- a/includes/filerepo/backend/FileBackendGroup.php +++ b/includes/filerepo/backend/FileBackendGroup.php @@ -124,7 +124,7 @@ class FileBackendGroup { * Get the backend object with a given name * * @param $name string - * @return FileBackendBase + * @return FileBackend * @throws MWException */ public function get( $name ) { @@ -144,7 +144,7 @@ class FileBackendGroup { * Get an appropriate backend object from a storage path * * @param $storagePath string - * @return FileBackendBase|null Backend or null on failure + * @return FileBackend|null Backend or null on failure */ public function backendFromPath( $storagePath ) { list( $backend, $c, $p ) = FileBackend::splitStoragePath( $storagePath ); diff --git a/includes/filerepo/backend/FileBackendMultiWrite.php b/includes/filerepo/backend/FileBackendMultiWrite.php index 956820755e..d09462ab71 100644 --- a/includes/filerepo/backend/FileBackendMultiWrite.php +++ b/includes/filerepo/backend/FileBackendMultiWrite.php @@ -20,17 +20,17 @@ * @ingroup FileBackend * @since 1.19 */ -class FileBackendMultiWrite extends FileBackendBase { - /** @var Array Prioritized list of FileBackend objects */ +class FileBackendMultiWrite extends FileBackend { + /** @var Array Prioritized list of FileBackendStore objects */ protected $backends = array(); // array of (backend index => backends) - protected $masterIndex = -1; // index of master backend + protected $masterIndex = -1; // integer; index of master backend /** * Construct a proxy backend that consists of several internal backends. * Additional $config params include: * 'backends' : Array of backend config and multi-backend settings. * Each value is the config used in the constructor of a - * FileBackend class, but with these additional settings: + * FileBackendStore class, but with these additional settings: * 'class' : The name of the backend class * 'isMultiMaster' : This must be set for one backend. * @param $config Array @@ -64,7 +64,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::doOperationsInternal() + * @see FileBackend::doOperationsInternal() */ final protected function doOperationsInternal( array $ops, array $opts ) { $status = Status::newGood(); @@ -196,10 +196,10 @@ class FileBackendMultiWrite extends FileBackendBase { * for a set of operations with that of a given internal backend. * * @param $ops Array List of file operation arrays - * @param $backend FileBackend + * @param $backend FileBackendStore * @return Array */ - protected function substOpBatchPaths( array $ops, FileBackend $backend ) { + protected function substOpBatchPaths( array $ops, FileBackendStore $backend ) { $newOps = array(); // operations foreach ( $ops as $op ) { $newOp = $op; // operation @@ -217,10 +217,10 @@ class FileBackendMultiWrite extends FileBackendBase { * Same as substOpBatchPaths() but for a single operation * * @param $op File operation array - * @param $backend FileBackend + * @param $backend FileBackendStore * @return Array */ - protected function substOpPaths( array $ops, FileBackend $backend ) { + protected function substOpPaths( array $ops, FileBackendStore $backend ) { $newOps = $this->substOpBatchPaths( array( $ops ), $backend ); return $newOps[0]; } @@ -229,10 +229,10 @@ class FileBackendMultiWrite extends FileBackendBase { * Substitute the backend of storage paths with an internal backend's name * * @param $paths Array|string List of paths or single string path - * @param $backend FileBackend + * @param $backend FileBackendStore * @return Array|string */ - protected function substPaths( $paths, FileBackend $backend ) { + protected function substPaths( $paths, FileBackendStore $backend ) { return preg_replace( '!^mwstore://' . preg_quote( $this->name ) . '/!', 'mwstore://' . $backend->getName() . '/', @@ -255,7 +255,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::doPrepare() + * @see FileBackend::doPrepare() */ public function doPrepare( array $params ) { $status = Status::newGood(); @@ -267,7 +267,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::doSecure() + * @see FileBackend::doSecure() */ public function doSecure( array $params ) { $status = Status::newGood(); @@ -279,7 +279,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::doClean() + * @see FileBackend::doClean() */ public function doClean( array $params ) { $status = Status::newGood(); @@ -291,7 +291,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::getFileList() + * @see FileBackend::getFileList() */ public function concatenate( array $params ) { // We are writing to an FS file, so we don't need to do this per-backend @@ -300,7 +300,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::fileExists() + * @see FileBackend::fileExists() */ public function fileExists( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -308,7 +308,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::getFileTimestamp() + * @see FileBackend::getFileTimestamp() */ public function getFileTimestamp( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -316,7 +316,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::getFileSize() + * @see FileBackend::getFileSize() */ public function getFileSize( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -324,7 +324,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::getFileStat() + * @see FileBackend::getFileStat() */ public function getFileStat( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -332,7 +332,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::getFileContents() + * @see FileBackend::getFileContents() */ public function getFileContents( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -340,7 +340,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::getFileSha1Base36() + * @see FileBackend::getFileSha1Base36() */ public function getFileSha1Base36( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -348,7 +348,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::getFileProps() + * @see FileBackend::getFileProps() */ public function getFileProps( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -356,7 +356,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::streamFile() + * @see FileBackend::streamFile() */ public function streamFile( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -364,7 +364,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::getLocalReference() + * @see FileBackend::getLocalReference() */ public function getLocalReference( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -372,7 +372,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::getLocalCopy() + * @see FileBackend::getLocalCopy() */ public function getLocalCopy( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -380,7 +380,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::getFileList() + * @see FileBackend::getFileList() */ public function getFileList( array $params ) { $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] ); @@ -388,7 +388,7 @@ class FileBackendMultiWrite extends FileBackendBase { } /** - * @see FileBackendBase::clearCache() + * @see FileBackend::clearCache() */ public function clearCache( array $paths = null ) { foreach ( $this->backends as $backend ) { diff --git a/includes/filerepo/backend/FileOp.php b/includes/filerepo/backend/FileOp.php index 092700b1cc..5197100d4f 100644 --- a/includes/filerepo/backend/FileOp.php +++ b/includes/filerepo/backend/FileOp.php @@ -18,7 +18,7 @@ abstract class FileOp { /** @var Array */ protected $params = array(); - /** @var FileBackendBase */ + /** @var FileBackendStore */ protected $backend; protected $state = self::STATE_NEW; // integer @@ -40,11 +40,11 @@ abstract class FileOp { /** * Build a new file operation transaction * - * @params $backend FileBackend + * @params $backend FileBackendStore * @params $params Array * @throws MWException */ - final public function __construct( FileBackendBase $backend, array $params ) { + final public function __construct( FileBackendStore $backend, array $params ) { $this->backend = $backend; list( $required, $optional ) = $this->allowedParams(); foreach ( $required as $name ) { @@ -387,7 +387,7 @@ class FileOpScopedPHPTimeout { /** * Store a file into the backend from a file on the file system. - * Parameters similar to FileBackend::storeInternal(), which include: + * Parameters similar to FileBackendStore::storeInternal(), which include: * src : source path on file system * dst : destination storage path * overwrite : do nothing and pass if an identical file exists at destination @@ -449,7 +449,7 @@ class StoreFileOp extends FileOp { /** * Create a file in the backend with the given content. - * Parameters similar to FileBackend::createInternal(), which include: + * Parameters similar to FileBackendStore::createInternal(), which include: * content : the raw file contents * dst : destination storage path * overwrite : do nothing and pass if an identical file exists at destination @@ -501,7 +501,7 @@ class CreateFileOp extends FileOp { /** * Copy a file from one storage path to another in the backend. - * Parameters similar to FileBackend::copyInternal(), which include: + * Parameters similar to FileBackendStore::copyInternal(), which include: * src : source storage path * dst : destination storage path * overwrite : do nothing and pass if an identical file exists at destination @@ -556,7 +556,7 @@ class CopyFileOp extends FileOp { /** * Move a file from one storage path to another in the backend. - * Parameters similar to FileBackend::moveInternal(), which include: + * Parameters similar to FileBackendStore::moveInternal(), which include: * src : source storage path * dst : destination storage path * overwrite : do nothing and pass if an identical file exists at destination @@ -617,7 +617,7 @@ class MoveFileOp extends FileOp { /** * Delete a file at the given storage path from the backend. - * Parameters similar to FileBackend::deleteInternal(), which include: + * Parameters similar to FileBackendStore::deleteInternal(), which include: * src : source storage path * ignoreMissingSource : don't return an error if the file does not exist */ diff --git a/includes/filerepo/backend/SwiftFileBackend.php b/includes/filerepo/backend/SwiftFileBackend.php index 79662eeddc..b0c7029621 100644 --- a/includes/filerepo/backend/SwiftFileBackend.php +++ b/includes/filerepo/backend/SwiftFileBackend.php @@ -19,7 +19,7 @@ * @ingroup FileBackend * @since 1.19 */ -class SwiftFileBackend extends FileBackend { +class SwiftFileBackend extends FileBackendStore { /** @var CF_Authentication */ protected $auth; // Swift authentication handler protected $authTTL; // integer seconds @@ -32,7 +32,7 @@ class SwiftFileBackend extends FileBackend { protected $connContainers = array(); // container object cache /** - * @see FileBackend::__construct() + * @see FileBackendStore::__construct() * Additional $config params include: * swiftAuthUrl : Swift authentication server URL * swiftUser : Swift user used by MediaWiki (account:username) @@ -63,7 +63,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::resolveContainerPath() + * @see FileBackendStore::resolveContainerPath() */ protected function resolveContainerPath( $container, $relStoragePath ) { if ( strlen( urlencode( $relStoragePath ) ) > 1024 ) { @@ -73,7 +73,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::isPathUsableInternal() + * @see FileBackendStore::isPathUsableInternal() */ public function isPathUsableInternal( $storagePath ) { list( $container, $rel ) = $this->resolveStoragePathReal( $storagePath ); @@ -94,7 +94,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doCopyInternal() + * @see FileBackendStore::doCopyInternal() */ protected function doCreateInternal( array $params ) { $status = Status::newGood(); @@ -156,7 +156,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doStoreInternal() + * @see FileBackendStore::doStoreInternal() */ protected function doStoreInternal( array $params ) { $status = Status::newGood(); @@ -224,7 +224,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doCopyInternal() + * @see FileBackendStore::doCopyInternal() */ protected function doCopyInternal( array $params ) { $status = Status::newGood(); @@ -279,7 +279,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doDeleteInternal() + * @see FileBackendStore::doDeleteInternal() */ protected function doDeleteInternal( array $params ) { $status = Status::newGood(); @@ -310,7 +310,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doPrepareInternal() + * @see FileBackendStore::doPrepareInternal() */ protected function doPrepareInternal( $fullCont, $dir, array $params ) { $status = Status::newGood(); @@ -355,7 +355,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doSecureInternal() + * @see FileBackendStore::doSecureInternal() */ protected function doSecureInternal( $fullCont, $dir, array $params ) { $status = Status::newGood(); @@ -389,7 +389,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doCleanInternal() + * @see FileBackendStore::doCleanInternal() */ protected function doCleanInternal( $fullCont, $dir, array $params ) { $status = Status::newGood(); @@ -433,7 +433,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doFileExists() + * @see FileBackendStore::doFileExists() */ protected function doGetFileStat( array $params ) { list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $params['src'] ); @@ -494,7 +494,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackendBase::getFileContents() + * @see FileBackend::getFileContents() */ public function getFileContents( array $params ) { list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $params['src'] ); @@ -521,7 +521,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::getFileListInternal() + * @see FileBackendStore::getFileListInternal() */ public function getFileListInternal( $fullCont, $dir, array $params ) { return new SwiftFileBackendFileList( $this, $fullCont, $dir ); @@ -554,7 +554,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doGetFileSha1base36() + * @see FileBackendStore::doGetFileSha1base36() */ public function doGetFileSha1base36( array $params ) { $stat = $this->getFileStat( $params ); @@ -566,7 +566,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doStreamFile() + * @see FileBackendStore::doStreamFile() */ protected function doStreamFile( array $params ) { $status = Status::newGood(); @@ -592,7 +592,6 @@ class SwiftFileBackend extends FileBackend { try { $output = fopen( 'php://output', 'w' ); - // FileBackend::streamFile() already checks existence $obj = new CF_Object( $cont, $srcRel, false, false ); // skip HEAD request $obj->stream( $output, $this->headersFromParams( $params ) ); } catch ( InvalidResponseException $e ) { // 404? connection problem? @@ -606,7 +605,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::getLocalCopy() + * @see FileBackendStore::getLocalCopy() */ public function getLocalCopy( array $params ) { list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $params['src'] ); @@ -722,7 +721,7 @@ class SwiftFileBackend extends FileBackend { } /** - * @see FileBackend::doClearCache() + * @see FileBackendStore::doClearCache() */ protected function doClearCache( array $paths = null ) { $this->connContainers = array(); // clear container object cache -- 2.20.1