* @deprecated since 1.19
*/
class FSRepo extends FileRepo {
+
+ /**
+ * @param $info array
+ * @throws MWException
+ */
function __construct( array $info ) {
if ( !isset( $info['backend'] ) ) {
// B/C settings...
var $oldFileFactory = false;
var $fileFactoryKey = false, $oldFileFactoryKey = false;
+ /**
+ * @param $info array|null
+ * @throws MWException
+ */
function __construct( array $info = null ) {
// Verify required settings presence
if(
* Check if a single zone or list of zones is defined for usage
*
* @param $doZones Array Only do a particular zones
+ * @throws MWException
* @return Status
*/
protected function initZones( $doZones = array() ) {
* The suffix, if supplied, is considered to be unencoded, and will be
* URL-encoded before being returned.
*
- * @param $suffix string
+ * @param $suffix string|bool
* @return string
*/
public function getVirtualUrl( $suffix = false ) {
* Use this function wisely.
*
* @param $url string
+ * @throws MWException
* @return string
*/
public function resolveVirtualUrl( $url ) {
* SHA-1 content hash.
*
* STUB
+ * @param $hash
* @return array
*/
public function findBySha1( $hash ) {
* self::OVERWRITE_SAME Overwrite the file if the destination exists and has the
* same contents as the source
* self::SKIP_LOCKING Skip any file locking when doing the store
+ * @throws MWException
* @return FileRepoStatus
*/
public function storeBatch( array $triplets, $flags = 0 ) {
* Each file can be a (zone, rel) pair, virtual url, storage path.
* It will try to delete each file, but ignores any errors that may occur.
*
- * @param $pairs array List of files to delete
+ * @param $files array List of files to delete
* @param $flags Integer: bitwise combination of the following flags:
* self::SKIP_LOCKING Skip any file locking when doing the deletions
* @return FileRepoStatus
* This function can be used to write to otherwise read-only foreign repos.
* This is intended for copying generated thumbnails into the repo.
*
- * @param $src Array List of tuples (file system path, virtual URL or storage path)
+ * @param $pairs Array List of tuples (file system path, virtual URL or storage path)
* @return FileRepoStatus
*/
public function quickImportBatch( array $pairs ) {
* This function can be used to write to otherwise read-only foreign repos.
* This does no locking nor journaling and is intended for purging thumbnails.
*
- * @param $path Array List of virtual URLs or storage paths
+ * @param $paths Array List of virtual URLs or storage paths
* @return FileRepoStatus
*/
public function quickPurgeBatch( array $paths ) {
* @param $triplets Array: (source, dest, archive) triplets as per publish()
* @param $flags Integer: bitfield, may be FileRepo::DELETE_SOURCE to indicate
* that the source files should be deleted if possible
+ * @throws MWException
* @return FileRepoStatus
*/
public function publishBatch( array $triplets, $flags = 0 ) {
* is a two-element array containing the source file path relative to the
* public root in the first element, and the archive file path relative
* to the deleted zone root in the second element.
+ * @throws MWException
* @return FileRepoStatus
*/
public function deleteBatch( array $sourceDestPairs ) {
* Get a relative path for a deletion archive key,
* e.g. s/z/a/ for sza251lrxrc1jad41h5mgilp8nysje52.jpg
*
+ * @param $key string
* @return string
*/
public function getDeletedHashPath( $key ) {
/**
* Create a new good result
*
+ * @param $value null|string
* @return FileRepoStatus
*/
public function newGood( $value = null ) {
protected $mQueryCache = array();
protected $mFileExists = array();
+ /**
+ * @param $info array|null
+ */
function __construct( $info ) {
global $wgLocalFileRepo;
parent::__construct( $info );
* Per docs in FileRepo, this needs to return false if we don't support versioned
* files. Well, we don't.
*
+ * @param $title Title
+ * @param $time string|bool
* @return File
*/
function newFile( $title, $time = false ) {
return parent::newFile( $title, $time );
}
+ /**
+ * @param $files array
+ * @return array
+ */
function fileExistsBatch( array $files ) {
$results = array();
foreach ( $files as $k => $f ) {
return $results;
}
+ /**
+ * @param $virtualUrl string
+ * @return bool
+ */
function getFileProps( $virtualUrl ) {
return false;
}
+ /**
+ * @param $query array
+ * @return string
+ */
function fetchImageQuery( $query ) {
global $wgMemc;
return FormatJson::decode( $this->mQueryCache[$url], true );
}
+ /**
+ * @param $data array
+ * @return bool|array
+ */
function getImageInfo( $data ) {
if( $data && isset( $data['query']['pages'] ) ) {
foreach( $data['query']['pages'] as $info ) {
return false;
}
+ /**
+ * @param $hash string
+ * @return array
+ */
function findBySha1( $hash ) {
$results = $this->fetchImageQuery( array(
'aisha1base36' => $hash,
return $ret;
}
+ /**
+ * @param $name string
+ * @param $width int
+ * @param $height int
+ * @param $result null
+ * @param $otherParams string
+ * @return bool
+ */
function getThumbUrl( $name, $width = -1, $height = -1, &$result = null, $otherParams = '' ) {
$data = $this->fetchImageQuery( array(
'titles' => 'File:' . $name,
* @param $name String is a dbkey form of a title
* @param $width
* @param $height
- * @param String $param Other rendering parameters (page number, etc) from handler's makeParamString.
+ * @param String $params Other rendering parameters (page number, etc) from handler's makeParamString.
* @return bool|string
*/
- function getThumbUrlFromCache( $name, $width, $height, $params="" ) {
+ function getThumbUrlFromCache( $name, $width, $height, $params = "" ) {
global $wgMemc;
// We can't check the local cache using FileRepo functions because
// we override fileExistsBatch(). We have to use the FileBackend directly.
/**
* @see FileRepo::getZoneUrl()
+ * @param $zone String
* @return String
*/
function getZoneUrl( $zone ) {
/**
* Get the local directory corresponding to one of the basic zones
+ * @param $zone string
* @return bool|null|string
*/
function getZonePath( $zone ) {
/**
* Like a Http:get request, but with custom User-Agent.
* @see Http:get
+ * @param $url string
+ * @param $timeout string
+ * @param $options array
* @return bool|String
*/
public static function httpGet( $url, $timeout = 'default', $options = array() ) {
}
}
+ /**
+ * @param $callback Array|string
+ * @throws MWException
+ */
function enumFiles( $callback ) {
throw new MWException( 'enumFiles is not supported by ' . get_class( $this ) );
}
+ /**
+ * @throws MWException
+ */
protected function assertWritableRepo() {
throw new MWException( get_class( $this ) . ': write operations are not supported.' );
}
var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
+ /**
+ * @param $info array|null
+ */
function __construct( $info ) {
parent::__construct( $info );
$this->dbType = $info['dbType'];
$this->hasSharedCache = $info['hasSharedCache'];
}
+ /**
+ * @return DatabaseBase
+ */
function getMasterDB() {
if ( !isset( $this->dbConn ) ) {
$this->dbConn = DatabaseBase::factory( $this->dbType,
return $this->dbConn;
}
+ /**
+ * @return DatabaseBase
+ */
function getSlaveDB() {
return $this->getMasterDB();
}
+ /**
+ * @return bool
+ */
function hasSharedCache() {
return $this->hasSharedCache;
}
var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
+ /**
+ * @param $info array|null
+ */
function __construct( $info ) {
parent::__construct( $info );
$this->wiki = $info['wiki'];
$this->hasSharedCache = $info['hasSharedCache'];
}
+ /**
+ * @return DatabaseBase
+ */
function getMasterDB() {
return wfGetDB( DB_MASTER, array(), $this->wiki );
}
+ /**
+ * @return DatabaseBase
+ */
function getSlaveDB() {
return wfGetDB( DB_SLAVE, array(), $this->wiki );
}
* @ingroup FileRepo
*/
class NullRepo extends FileRepo {
+
+ /**
+ * @param $info array|null
+ */
function __construct( $info ) {}
protected function assertWritableRepo() {
return $image;
}
+ /**
+ * @param $inputItems array
+ * @return array
+ */
function findFiles( $inputItems ) {
if ( !$this->reposInitialised ) {
$this->initialiseRepos();
/**
* Interface for FileRepo::checkRedirect()
+ * @param $title Title
* @return bool
*/
function checkRedirect( Title $title ) {
/**
* Get the repo instance with a given key.
+ * @param $index string|int
* @return bool|LocalRepo
*/
function getRepo( $index ) {
return false;
}
}
+
/**
* Get the repo instance by its name
+ * @param $name string
* @return bool
*/
function getRepoByName( $name ) {
$this->initialiseRepos();
}
foreach ( $this->foreignRepos as $repo ) {
- if ( $repo->name == $name)
+ if ( $repo->name == $name ) {
return $repo;
+ }
}
return false;
}
/**
* Split a virtual URL into repo, zone and rel parts
* @param $url string
+ * @throws MWException
* @return array containing repo, zone and rel
*/
function splitVirtualUrl( $url ) {
return $bits;
}
+ /**
+ * @param $fileName string
+ * @return array
+ */
function getFileProps( $fileName ) {
if ( FileRepo::isVirtualUrl( $fileName ) ) {
list( $repoName, /* $zone */, /* $rel */ ) = $this->splitVirtualUrl( $fileName );
/**
* Sets up the file object
*
- * @param String $path Path to temporary file on local disk
+ * @param $path string Path to temporary file on local disk
+ * @throws MWException
*/
public function __construct( $path ) {
if ( FileBackend::isStoragePath( $path ) ) {
/**
* Exract image size information
*
+ * @param $gis array
* @return Array
*/
protected function extractImageSizeInfo( array $gis ) {
/**
* @see FileBackendStore::resolveContainerPath()
+ * @param $container string
+ * @param $relStoragePath string
* @return null|string
*/
protected function resolveContainerPath( $container, $relStoragePath ) {
return array_pop( $this->hadWarningErrors ); // pop from stack
}
+ /**
+ * @return bool
+ */
private function handleWarning() {
$this->hadWarningErrors[count( $this->hadWarningErrors ) - 1] = true;
return true; // suppress from PHP handler
public $cmd; // string; shell command
public $chmodPath; // string; file to chmod
+ /**
+ * @param $backend
+ * @param $params array
+ * @param $call
+ * @param $cmd
+ * @param $chmodPath null
+ */
public function __construct( $backend, array $params, $call, $cmd, $chmodPath = null ) {
$this->backend = $backend;
$this->params = $params;
/**
* @param $dir string file system directory
+ * @param $params array
*/
public function __construct( $dir, array $params ) {
$dir = realpath( $dir ); // normalize
* 'concurrency' : How many file operations can be done in parallel.
*
* @param $config Array
+ * @throws MWException
*/
public function __construct( array $config ) {
$this->name = $config['name'];
* $params include:
* dir : storage directory
*
+ * @param $params array
* @return bool|null Returns null on failure
* @since 1.20
*/
* dir : storage directory
* topOnly : only return direct child dirs of the directory
*
+ * @param $params array
* @return Traversable|Array|null Returns null on failure
* @since 1.20
*/
* $params include:
* dir : storage directory
*
+ * @param $params array
* @return Traversable|Array|null Returns null on failure
* @since 1.20
*/
* dir : storage directory
* topOnly : only return direct child files of the directory (@since 1.20)
*
+ * @param $params array
* @return Traversable|Array|null Returns null on failure
*/
abstract public function getFileList( array $params );
* $params include:
* dir : storage directory
*
+ * @param $params array
* @return Traversable|Array|null Returns null on failure
* @since 1.20
*/
/**
* Same as substOpBatchPaths() but for a single operation
*
- * @param $op File operation array
+ * @param $ops array File operation array
* @param $backend FileBackendStore
* @return Array
*/
/**
* @see FileBackend::doSecure()
+ * @param $params array
* @return Status
*/
protected function doSecure( array $params ) {
/**
* @see FileBackend::doClean()
+ * @param $params array
* @return Status
*/
protected function doClean( array $params ) {
/**
* @see FileBackend::concatenate()
+ * @param $params array
+ * @return Status
*/
public function concatenate( array $params ) {
// We are writing to an FS file, so we don't need to do this per-backend
/**
* @see FileBackend::fileExists()
+ * @param $params array
*/
public function fileExists( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileTimestamp()
+ * @param $params array
+ * @return bool|string
*/
public function getFileTimestamp( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileSize()
+ * @param $params array
+ * @return bool|int
*/
public function getFileSize( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileStat()
+ * @param $params array
+ * @return Array|bool|null
*/
public function getFileStat( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileContents()
+ * @param $params array
+ * @return bool|string
*/
public function getFileContents( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileSha1Base36()
+ * @param $params array
+ * @return bool|string
*/
public function getFileSha1Base36( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileProps()
+ * @param $params array
+ * @return Array
*/
public function getFileProps( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::streamFile()
+ * @param $params array
+ * @return \Status
*/
public function streamFile( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getLocalReference()
+ * @param $params array
+ * @return FSFile|null
*/
public function getLocalReference( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getLocalCopy()
+ * @param $params array
+ * @return null|TempFSFile
*/
public function getLocalCopy( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::directoryExists()
+ * @param $params array
+ * @return bool|null
*/
public function directoryExists( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getSubdirectoryList()
+ * @param $params array
+ * @return Array|null|Traversable
*/
public function getDirectoryList( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileList()
+ * @param $params array
+ * @return Array|null|\Traversable
*/
public function getFileList( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackendStore::executeOpHandlesInternal()
* @return Array List of corresponding Status objects
- * @throws MWException
*/
protected function doExecuteOpHandlesInternal( array $fileOpHandles ) {
foreach ( $fileOpHandles as $fileOpHandle ) { // OK if empty
* Any empty suffix means the container is not sharded.
*
* @param $container string Container name
- * @param $relStoragePath string Storage path relative to the container
+ * @param $relPath string Storage path relative to the container
* @return string|null Returns null if shard could not be determined
*/
final protected function getContainerShard( $container, $relPath ) {
*
* @param $container string Resolved container name
* @param $val mixed Information to cache
- * @return void
*/
final protected function setContainerCache( $container, $val ) {
$this->memCache->set( $this->containerCacheKey( $container ), $val, 14*86400 );
/**
* Delete the cached info for a container
*
- * @param $containers string Resolved container name
- * @return void
+ * @param $container string Resolved container name
*/
final protected function deleteContainerCache( $container ) {
if ( !$this->memCache->delete( $this->containerCacheKey( $container ) ) ) {
*
* @param $path string Storage path
* @param $val mixed Information to cache
- * @return void
*/
final protected function setFileCache( $path, $val ) {
$this->memCache->set( $this->fileCacheKey( $path ), $val, 7*86400 );
* Delete the cached stat info for a file path
*
* @param $path string Storage path
- * @return void
*/
final protected function deleteFileCache( $path ) {
if ( !$this->memCache->delete( $this->fileCacheKey( $path ) ) ) {
* Iterator for listing directories
*/
class FileBackendStoreShardDirIterator extends FileBackendStoreShardListIterator {
+ /**
+ * @param string $container
+ * @param string $dir
+ * @param array $params
+ * @return Array|null|Traversable
+ */
protected function listFromShard( $container, $dir, array $params ) {
return $this->backend->getDirectoryListInternal( $container, $dir, $params );
}
* Iterator for listing regular files
*/
class FileBackendStoreShardFileIterator extends FileBackendStoreShardListIterator {
+ /**
+ * @param string $container
+ * @param string $dir
+ * @param array $params
+ * @return Array|null|Traversable
+ */
protected function listFromShard( $container, $dir, array $params ) {
return $this->backend->getFileListInternal( $container, $dir, $params );
}
* overwriteSame : override any existing file at destination
*/
class StoreFileOp extends FileOp {
+
+ /**
+ * @return array
+ */
protected function allowedParams() {
return array( array( 'src', 'dst' ), array( 'overwrite', 'overwriteSame' ) );
}
+ /**
+ * @param $predicates array
+ * @return Status
+ */
protected function doPrecheck( array &$predicates ) {
$status = Status::newGood();
// Check if the source file exists on the file system
return $status; // safe to call attempt()
}
+ /**
+ * @return Status
+ */
protected function doAttempt() {
// Store the file at the destination
if ( !$this->destSameAsSource ) {
return Status::newGood();
}
+ /**
+ * @return bool|string
+ */
protected function getSourceSha1Base36() {
wfSuppressWarnings();
$hash = sha1_file( $this->params['src'] );
return $status; // safe to call attempt()
}
+ /**
+ * @return Status
+ */
protected function doAttempt() {
if ( !$this->destSameAsSource ) {
// Create the file at the destination
return Status::newGood();
}
+ /**
+ * @return bool|String
+ */
protected function getSourceSha1Base36() {
return wfBaseConvert( sha1( $this->params['content'] ), 16, 36, 31 );
}
+ /**
+ * @return array
+ */
protected function doStoragePathsChanged() {
return array( $this->params['dst'] );
}
* overwriteSame : override any existing file at destination
*/
class CopyFileOp extends FileOp {
+
+ /**
+ * @return array
+ */
protected function allowedParams() {
return array( array( 'src', 'dst' ), array( 'overwrite', 'overwriteSame' ) );
}
+ /**
+ * @param $predicates array
+ * @return Status
+ */
protected function doPrecheck( array &$predicates ) {
$status = Status::newGood();
// Check if the source file exists
return $status; // safe to call attempt()
}
+ /**
+ * @return Status
+ */
protected function doAttempt() {
// Do nothing if the src/dst paths are the same
if ( $this->params['src'] !== $this->params['dst'] ) {
return Status::newGood();
}
+ /**
+ * @return array
+ */
protected function doStoragePathsRead() {
return array( $this->params['src'] );
}
+ /**
+ * @return array
+ */
protected function doStoragePathsChanged() {
return array( $this->params['dst'] );
}
* overwriteSame : override any existing file at destination
*/
class MoveFileOp extends FileOp {
+ /**
+ * @return array
+ */
protected function allowedParams() {
return array( array( 'src', 'dst' ), array( 'overwrite', 'overwriteSame' ) );
}
+ /**
+ * @param $predicates array
+ * @return Status
+ */
protected function doPrecheck( array &$predicates ) {
$status = Status::newGood();
// Check if the source file exists
return $status; // safe to call attempt()
}
+ /**
+ * @return Status
+ */
protected function doAttempt() {
// Do nothing if the src/dst paths are the same
if ( $this->params['src'] !== $this->params['dst'] ) {
return Status::newGood();
}
+ /**
+ * @return array
+ */
protected function doStoragePathsRead() {
return array( $this->params['src'] );
}
+ /**
+ * @return array
+ */
protected function doStoragePathsChanged() {
return array( $this->params['src'], $this->params['dst'] );
}
* ignoreMissingSource : don't return an error if the file does not exist
*/
class DeleteFileOp extends FileOp {
+ /**
+ * @return array
+ */
protected function allowedParams() {
return array( array( 'src' ), array( 'ignoreMissingSource' ) );
}
protected $needsDelete = true;
+ /**
+ * @param array $predicates
+ * @return Status
+ */
protected function doPrecheck( array &$predicates ) {
$status = Status::newGood();
// Check if the source file exists
return $status; // safe to call attempt()
}
+ /**
+ * @return Status
+ */
protected function doAttempt() {
if ( $this->needsDelete ) {
// Delete the source file
return Status::newGood();
}
+ /**
+ * @return array
+ */
protected function doStoragePathsChanged() {
return array( $this->params['src'] );
}
* within any given sub-batch do not depend on each other.
* This will abort remaining ops on failure.
*
- * @param $performOps Array
+ * @param $pPerformOps Array
* @param $status Status
* @return bool Success
*/
}
// Try to do all the operations concurrently...
$statuses = $statuses + $backend->executeOpHandlesInternal( $opHandles );
- // Marshall and merge all the responses...
+ // Marshall and merge all the responses (blocking)...
foreach ( $performOpsBatch as $i => $fileOp ) {
if ( !$fileOp->failed() ) { // failed => already has Status
$subStatus = $statuses[$i];
* Construct a new instance from configuration.
* $config includes:
* 'wiki' : wiki name to use for LoadBalancer
- *
+ *
* @param $config Array
*/
protected function __construct( array $config ) {
* Construct a new instance from configuration.
* $config includes:
* 'ttlDays' : days to keep log entries around (false means "forever")
- *
+ *
* @param $config Array
*/
protected function __construct( array $config ) {
*
* @param $config Array
* @param $backend string A registered file backend name
+ * @throws MWException
* @return FileJournal
*/
final public static function factory( array $config, $backend ) {
/**
* Get a statistically unique ID string
- *
+ *
* @return string <9 char TS_MW timestamp in base 36><22 random base 36 chars>
*/
final public function getTimestampedUUID() {
* path : The storage path of the file
* newSha1 : The final base 36 SHA-1 of the file
* Note that 'false' should be used as the SHA-1 for non-existing files.
- *
+ *
* @param $entries Array List of file operations (each an array of parameters)
* @param $batchId string UUID string that identifies the operation batch
* @return Status
/**
* @see FileJournal::logChangeBatch()
- *
+ *
* @param $entries Array List of file operations (each an array of parameters)
* @param $batchId string UUID string that identifies the operation batch
* @return Status
class NullFileJournal extends FileJournal {
/**
* @see FileJournal::logChangeBatch()
+ * @param $entries array
+ * @param $batchId string
* @return Status
*/
protected function doLogChangeBatch( array $entries, $batchId ) {
/**
* @see LockManager::doLock()
+ * @param $paths array
+ * @param $type int
* @return Status
*/
protected function doLock( array $paths, $type ) {
/**
* @see LockManager::doUnlock()
+ * @param $paths array
+ * @param $type int
* @return Status
*/
protected function doUnlock( array $paths, $type ) {
self::LOCK_EX => self::LOCK_EX
);
+ /**
+ * @param $lockDb string
+ * @param $db DatabaseBase
+ */
protected function initConnection( $lockDb, DatabaseBase $db ) {
# Let this transaction see lock rows from other transactions
$db->query( "SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;" );
}
+ /**
+ * @param $lockDb string
+ * @param $paths array
+ * @param $type int
+ * @return bool
+ */
protected function doLockingQuery( $lockDb, array $paths, $type ) {
$db = $this->getConnection( $lockDb );
if ( !$db ) {
/**
* @see LockManager::doLock()
+ * @param $paths array
+ * @param $type int
* @return Status
*/
protected function doLock( array $paths, $type ) {
/**
* @see LockManager::doUnlock()
+ * @param $paths array
+ * @param $type int
* @return Status
*/
protected function doUnlock( array $paths, $type ) {
return $status;
}
+ /**
+ * @param $path string
+ * @param $handlesToClose array
+ * @return Status
+ */
private function closeLockHandles( $path, array $handlesToClose ) {
$status = Status::newGood();
foreach ( $handlesToClose as $handle ) {
return $status;
}
+ /**
+ * @param $path string
+ * @return Status
+ */
private function pruneKeyLockFiles( $path ) {
$status = Status::newGood();
if ( !count( $this->locksHeld[$path] ) ) {
/**
* @see LockManager::doLock()
+ * @param $paths array
+ * @param $type int
* @return Status
*/
protected function doLock( array $paths, $type ) {
/**
* @see LockManager::doUnlock()
+ * @param $paths array
+ * @param $type int
* @return Status
*/
protected function doUnlock( array $paths, $type ) {
class NullLockManager extends LockManager {
/**
* @see LockManager::doLock()
+ * @param $paths array
+ * @param $type int
* @return Status
*/
protected function doLock( array $paths, $type ) {
/**
* @see LockManager::doUnlock()
+ * @param $paths array
+ * @param $type int
* @return Status
*/
protected function doUnlock( array $paths, $type ) {
protected $managers = array();
protected function __construct() {}
+
/**
* @return LockManagerGroup
*/
*/
protected $url, $extension, $name, $path, $hashPath, $pageCount, $transformScript;
+ protected $redirectTitle;
+
/**
* @var bool
*/
*
* @param $title Title|string
* @param $exception string|bool Use 'exception' to throw an error on bad titles
+ * @throws MWException
* @return Title|null
*/
static function normalizeTitle( $title, $exception = false ) {
*
* @return array
*/
- function getHistory($limit = null, $start = null, $end = null, $inc=true) {
+ function getHistory( $limit = null, $start = null, $end = null, $inc=true ) {
return array();
}
}
// Dummy functions...
+
+ /**
+ * @return bool
+ */
public function exists() {
return $this->mExists;
}
+ /**
+ * @return bool
+ */
public function getPath() {
return false;
}
+ /**
+ * @param Array $params
+ * @param int $flags
+ * @return bool|MediaTransformOutput
+ */
function transform( $params, $flags = 0 ) {
if( !$this->canRender() ) {
// show icon
}
// Info we can get from API...
+
+ /**
+ * @param $page int
+ * @return int|number
+ */
public function getWidth( $page = 1 ) {
return isset( $this->mInfo['width'] ) ? intval( $this->mInfo['width'] ) : 0;
}
return isset( $this->mInfo['height'] ) ? intval( $this->mInfo['height'] ) : 0;
}
+ /**
+ * @return bool|null|string
+ */
public function getMetadata() {
if ( isset( $this->mInfo['metadata'] ) ) {
return serialize( self::parseMetadata( $this->mInfo['metadata'] ) );
return null;
}
+ /**
+ * @param $metadata array
+ * @return array
+ */
public static function parseMetadata( $metadata ) {
if( !is_array( $metadata ) ) {
return $metadata;
return $ret;
}
+ /**
+ * @return bool|int|null
+ */
public function getSize() {
return isset( $this->mInfo['size'] ) ? intval( $this->mInfo['size'] ) : null;
}
+ /**
+ * @return null|string
+ */
public function getUrl() {
return isset( $this->mInfo['url'] ) ? strval( $this->mInfo['url'] ) : null;
}
+ /**
+ * @param string $method
+ * @return int|null|string
+ */
public function getUser( $method='text' ) {
return isset( $this->mInfo['user'] ) ? strval( $this->mInfo['user'] ) : null;
}
+ /**
+ * @return null|string
+ */
public function getDescription() {
return isset( $this->mInfo['comment'] ) ? strval( $this->mInfo['comment'] ) : null;
}
+ /**
+ * @return null|String
+ */
function getSha1() {
return isset( $this->mInfo['sha1'] )
? wfBaseConvert( strval( $this->mInfo['sha1'] ), 16, 36, 31 )
: null;
}
+ /**
+ * @return bool|Mixed|string
+ */
function getTimestamp() {
return wfTimestamp( TS_MW,
isset( $this->mInfo['timestamp'] )
);
}
+ /**
+ * @return string
+ */
function getMimeType() {
if( !isset( $this->mInfo['mime'] ) ) {
$magic = MimeMagic::singleton();
return $this->mInfo['mime'];
}
- /// @todo FIXME: May guess wrong on file types that can be eg audio or video
+ /**
+ * @todo FIXME: May guess wrong on file types that can be eg audio or video
+ * @return int|string
+ */
function getMediaType() {
$magic = MimeMagic::singleton();
return $magic->getMediaType( null, $this->getMimeType() );
}
+ /**
+ * @return bool|string
+ */
function getDescriptionUrl() {
return isset( $this->mInfo['descriptionurl'] )
? $this->mInfo['descriptionurl']
/**
* Only useful if we're locally caching thumbs anyway...
+ * @param $suffix string
* @return null|string
*/
function getThumbPath( $suffix = '' ) {
}
}
+ /**
+ * @return array
+ */
function getThumbnails() {
$dir = $this->getThumbPath( $this->getName() );
$iter = $this->repo->getBackend()->getFileList( array( 'dir' => $dir ) );
$wgMemc->delete( $key );
}
+ /**
+ * @param $options array
+ */
function purgeThumbnails( $options = array() ) {
global $wgMemc;
return $file;
}
+ /**
+ * @param $srcPath String
+ * @param $flags int
+ * @throws MWException
+ */
function publish( $srcPath, $flags = 0 ) {
$this->readOnlyError();
}
+ /**
+ * @param $oldver
+ * @param $desc string
+ * @param $license string
+ * @param $copyStatus string
+ * @param $source string
+ * @param $watch bool
+ * @param $timestamp bool|string
+ * @throws MWException
+ */
function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '',
$watch = false, $timestamp = false ) {
$this->readOnlyError();
}
+ /**
+ * @param $versions array
+ * @param $unsuppress bool
+ * @throws MWException
+ */
function restore( $versions = array(), $unsuppress = false ) {
$this->readOnlyError();
}
+ /**
+ * @param $reason string
+ * @param $suppress bool
+ * @throws MWException
+ */
function delete( $reason, $suppress = false ) {
$this->readOnlyError();
}
+ /**
+ * @param $target Title
+ * @throws MWException
+ */
function move( $target ) {
$this->readOnlyError();
}
const CACHE_VERSION = 1;
const MAX_CACHE_ROWS = 20;
+ /**
+ * @param $title Title
+ * @param $repo FileRepo
+ * @param $time null
+ * @return OldLocalFile
+ * @throws MWException
+ */
static function newFromTitle( $title, $repo, $time = null ) {
# The null default value is only here to avoid an E_STRICT
if ( $time === null ) {
return new self( $title, $repo, $time, null );
}
+ /**
+ * @param $title Title
+ * @param $repo FileRepo
+ * @param $archiveName
+ * @return OldLocalFile
+ */
static function newFromArchiveName( $title, $repo, $archiveName ) {
return new self( $title, $repo, null, $archiveName );
}
+ /**
+ * @param $row
+ * @param $repo FileRepo
+ * @return OldLocalFile
+ */
static function newFromRow( $row, $repo ) {
$title = Title::makeTitle( NS_FILE, $row->oi_name );
$file = new self( $title, $repo, null, $row->oi_archive_name );
* @param $repo FileRepo
* @param $time String: timestamp or null to load by archive name
* @param $archiveName String: archive name or null to load by timestamp
+ * @throws MWException
*/
function __construct( $title, $repo, $time, $archiveName ) {
parent::__construct( $title, $repo );
}
}
+ /**
+ * @return bool
+ */
function getCacheKey() {
return false;
}
+ /**
+ * @return String
+ */
function getArchiveName() {
if ( !isset( $this->archive_name ) ) {
$this->load();
return $this->archive_name;
}
+ /**
+ * @return bool
+ */
function isOld() {
return true;
}
+ /**
+ * @return bool
+ */
function isVisible() {
return $this->exists() && !$this->isDeleted(File::DELETED_FILE);
}
wfProfileOut( __METHOD__ );
}
+ /**
+ * @param $prefix string
+ * @return array
+ */
function getCacheFields( $prefix = 'img_' ) {
$fields = parent::getCacheFields( $prefix );
$fields[] = $prefix . 'archive_name';
return $fields;
}
+ /**
+ * @return string
+ */
function getRel() {
return 'archive/' . $this->getHashPath() . $this->getArchiveName();
}
+ /**
+ * @return string
+ */
function getUrlRel() {
return 'archive/' . $this->getHashPath() . rawurlencode( $this->getArchiveName() );
}
$this->load();
return Revision::userCanBitfield( $this->deleted, $field, $user );
}
-
+
/**
* Upload a file directly into archive. Generally for Special:Import.
- *
+ *
* @param $srcPath string File system path of the source file
- * @param $archiveName string Full archive name of the file, in the form
- * $timestamp!$filename, where $filename must match $this->getName()
+ * @param $archiveName string Full archive name of the file, in the form
+ * $timestamp!$filename, where $filename must match $this->getName()
*
+ * @param $timestamp string
+ * @param $comment string
+ * @param $user
+ * @param $flags int
* @return FileRepoStatus
*/
function uploadOld( $srcPath, $archiveName, $timestamp, $comment, $user, $flags = 0 ) {
return $status;
}
-
+
/**
* Record a file upload in the oldimage table, without adding log entries.
- *
+ *
* @param $srcPath string File system path to the source file
* @param $archiveName string The archive name of the file
+ * @param $timestamp string
* @param $comment string Upload comment
* @param $user User User who did this upload
* @return bool
* @ingroup FileAbstraction
*/
class UnregisteredLocalFile extends File {
- var $title, $path, $mime, $dims;
+ var $title, $path, $mime, $dims, $metadata;
/**
* @var MediaHandler
/**
* Create an UnregisteredLocalFile based on a path or a (title,repo) pair.
* A FileRepo object is not required here, unlike most other File classes.
- *
+ *
* @throws MWException
* @param $title Title|bool
- * @param $repo FileRepo
- * @param $path string
- * @param $mime string
+ * @param $repo FileRepo|bool
+ * @param $path string|bool
+ * @param $mime string|bool
*/
function __construct( $title = false, $repo = false, $path = false, $mime = false ) {
if ( !( $title && $repo ) && !$path ) {
$this->dims = array();
}
+ /**
+ * @param $page int
+ * @return bool
+ */
private function cachePageDimensions( $page = 1 ) {
if ( !isset( $this->dims[$page] ) ) {
if ( !$this->getHandler() ) {
return $this->dims[$page];
}
+ /**
+ * @param $page int
+ * @return number
+ */
function getWidth( $page = 1 ) {
$dim = $this->cachePageDimensions( $page );
return $dim['width'];
}
+ /**
+ * @param $page int
+ * @return number
+ */
function getHeight( $page = 1 ) {
$dim = $this->cachePageDimensions( $page );
return $dim['height'];
}
+ /**
+ * @return bool|string
+ */
function getMimeType() {
if ( !isset( $this->mime ) ) {
$magic = MimeMagic::singleton();
return $this->mime;
}
+ /**
+ * @param $filename String
+ * @return Array|bool
+ */
function getImageSize( $filename ) {
if ( !$this->getHandler() ) {
return false;
return $this->handler->getImageSize( $this, $this->getLocalRefPath() );
}
+ /**
+ * @return bool
+ */
function getMetadata() {
if ( !isset( $this->metadata ) ) {
if ( !$this->getHandler() ) {
return $this->metadata;
}
+ /**
+ * @return bool|string
+ */
function getURL() {
if ( $this->repo ) {
return $this->repo->getZoneUrl( 'public' ) . '/' .
}
}
+ /**
+ * @return bool|int
+ */
function getSize() {
$this->assertRepoDefined();
$props = $this->repo->getFileProps( $this->path );