* Various documentation improvements.
* Moved a few protected FileBackendStoreShardListIterator functions down. Same with normalizeContainerPath().
*/
/**
- * Class for a file system (FS) based file backend.
+ * @brief Class for a file system (FS) based file backend.
*
* All "containers" each map to a directory under the backend's base directory.
* For backwards-compatibility, some container paths can be set to custom paths.
}
}
+ /**
+ * @see Iterator::current()
+ * @return string|bool String or false
+ */
public function current() {
// Return only the relative path and normalize slashes to FileBackend-style
// Make sure to use the realpath since the suffix is based upon that
substr( realpath( $this->iter->current() ), $this->suffixStart ) );
}
+ /**
+ * @see Iterator::key()
+ * @return integer
+ */
public function key() {
return $this->pos;
}
+ /**
+ * @see Iterator::next()
+ * @return void
+ */
public function next() {
try {
$this->iter->next();
++$this->pos;
}
+ /**
+ * @see Iterator::rewind()
+ * @return void
+ */
public function rewind() {
$this->pos = 0;
try {
}
}
+ /**
+ * @see Iterator::valid()
+ * @return bool
+ */
public function valid() {
return $this->iter && $this->iter->valid();
}
*/
/**
- * Base class for all file backend classes (including multi-write backends).
+ * @brief Base class for all file backend classes (including multi-write backends).
*
* This class defines the methods as abstract that subclasses must implement.
* Outside callers can assume that all backends will have these functions.
return null;
}
+ /**
+ * Get the parent storage directory of a storage path.
+ * This returns a path like "mwstore://backend/container",
+ * "mwstore://backend/container/...", or null if there is no parent.
+ *
+ * @param $storagePath string
+ * @return string|null
+ */
+ final public static function parentStoragePath( $storagePath ) {
+ $storagePath = dirname( $storagePath );
+ list( $b, $cont, $rel ) = self::splitStoragePath( $storagePath );
+ return ( $rel === null ) ? null : $storagePath;
+ }
+
+ /**
+ * Get the final extension from a storage or FS path
+ *
+ * @param $path string
+ * @return string
+ */
+ final public static function extensionFromPath( $path ) {
+ $i = strrpos( $path, '.' );
+ return strtolower( $i ? substr( $path, $i + 1 ) : '' );
+ }
+
/**
* Validate and normalize a relative storage path.
* Null is returned if the path involves directory traversal.
}
return $path;
}
-
- /**
- * Get the parent storage directory of a storage path.
- * This returns a path like "mwstore://backend/container",
- * "mwstore://backend/container/...", or null if there is no parent.
- *
- * @param $storagePath string
- * @return string|null
- */
- final public static function parentStoragePath( $storagePath ) {
- $storagePath = dirname( $storagePath );
- list( $b, $cont, $rel ) = self::splitStoragePath( $storagePath );
- return ( $rel === null ) ? null : $storagePath;
- }
-
- /**
- * Get the final extension from a storage or FS path
- *
- * @param $path string
- * @return string
- */
- final public static function extensionFromPath( $path ) {
- $i = strrpos( $path, '.' );
- return strtolower( $i ? substr( $path, $i + 1 ) : '' );
- }
}
$this->params = $params;
}
+ /**
+ * @see Iterator::current()
+ * @return string|bool String or false
+ */
public function current() {
if ( is_array( $this->iter ) ) {
return current( $this->iter );
}
}
+ /**
+ * @see Iterator::key()
+ * @return integer
+ */
public function key() {
return $this->pos;
}
+ /**
+ * @see Iterator::next()
+ * @return void
+ */
public function next() {
++$this->pos;
if ( is_array( $this->iter ) ) {
}
/**
- * If the iterator for this container shard is out of items,
- * then move on to the next container that has items.
- * If there are none, then it advances to the last container.
+ * @see Iterator::rewind()
+ * @return void
*/
- protected function nextShardIteratorIfNotValid() {
- while ( !$this->valid() ) {
- if ( ++$this->curShard >= count( $this->shardSuffixes ) ) {
- break; // no more container shards
- }
- $this->setIteratorFromCurrentShard();
- }
- }
-
- protected function setIteratorFromCurrentShard() {
- $suffix = $this->shardSuffixes[$this->curShard];
- $this->iter = $this->backend->getFileListInternal(
- "{$this->container}{$suffix}", $this->directory, $this->params );
- }
-
public function rewind() {
$this->pos = 0;
$this->curShard = 0;
$this->nextShardIteratorIfNotValid();
}
+ /**
+ * @see Iterator::valid()
+ * @return bool
+ */
public function valid() {
if ( $this->iter == null ) {
return false; // some failure?
return $this->iter->valid();
}
}
+
+ /**
+ * If the list iterator for this container shard is out of items,
+ * then move on to the next container that has items.
+ * If there are none, then it advances to the last container.
+ */
+ protected function nextShardIteratorIfNotValid() {
+ while ( !$this->valid() ) {
+ if ( ++$this->curShard >= count( $this->shardSuffixes ) ) {
+ break; // no more container shards
+ }
+ $this->setIteratorFromCurrentShard();
+ }
+ }
+
+ /**
+ * Set the list iterator to that of the current container shard
+ */
+ protected function setIteratorFromCurrentShard() {
+ $suffix = $this->shardSuffixes[$this->curShard];
+ $this->iter = $this->backend->getFileListInternal(
+ "{$this->container}{$suffix}", $this->directory, $this->params );
+ }
}
*/
/**
- * Class for an OpenStack Swift based file backend.
+ * @brief Class for an OpenStack Swift based file backend.
*
* This requires the SwiftCloudFiles MediaWiki extension, which includes
* the php-cloudfiles library (https://github.com/rackspace/php-cloudfiles).
}
}
+ /**
+ * @see Iterator::current()
+ * @return string|bool String or false
+ */
public function current() {
return substr( current( $this->bufferIter ), $this->suffixStart );
}
+ /**
+ * @see Iterator::key()
+ * @return integer
+ */
public function key() {
return $this->pos;
}
+ /**
+ * @see Iterator::next()
+ * @return void
+ */
public function next() {
// Advance to the next file in the page
next( $this->bufferIter );
}
}
+ /**
+ * @see Iterator::rewind()
+ * @return void
+ */
public function rewind() {
$this->pos = 0;
$this->bufferAfter = null;
);
}
+ /**
+ * @see Iterator::valid()
+ * @return bool
+ */
public function valid() {
return ( current( $this->bufferIter ) !== false ); // no paths can have this value
}
$this->lockDir = $config['lockDirectory'];
}
+ /**
+ * @see LockManager::doLock()
+ * @return Status
+ */
protected function doLock( array $paths, $type ) {
$status = Status::newGood();
return $status;
}
+ /**
+ * @see LockManager::doUnlock()
+ * @return Status
+ */
protected function doUnlock( array $paths, $type ) {
$status = Status::newGood();
$this->session = wfBaseConvert( sha1( $this->session ), 16, 36, 31 );
}
+ /**
+ * @see LockManager::doLock()
+ * @return Status
+ */
protected function doLock( array $paths, $type ) {
$status = Status::newGood();
return $status;
}
+ /**
+ * @see LockManager::doUnlock()
+ * @return Status
+ */
protected function doUnlock( array $paths, $type ) {
$status = Status::newGood();
*/
/**
- * Class for handling resource locking.
+ * @brief Class for handling resource locking.
*
* Locks on resource keys can either be shared or exclusive.
*
* @since 1.19
*/
class NullLockManager extends LockManager {
+ /**
+ * @see LockManager::doLock()
+ * @return Status
+ */
protected function doLock( array $paths, $type ) {
return Status::newGood();
}
+ /**
+ * @see LockManager::doUnlock()
+ * @return Status
+ */
protected function doUnlock( array $paths, $type ) {
return Status::newGood();
}