if ( $this->oldFileFactory ) {
return call_user_func( $this->oldFileFactory, $title, $this, $time );
} else {
- return false;
+ return null;
}
} else {
return call_user_func( $this->fileFactory, $title, $this );
* 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
- * @return FileRepoStatus
+ * @return Status
*/
public function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
$this->assertWritableRepo(); // fail out if read-only
* same contents as the source
* self::SKIP_LOCKING Skip any file locking when doing the store
* @throws MWException
- * @return FileRepoStatus
+ * @return Status
*/
public function storeBatch( array $triplets, $flags = 0 ) {
$this->assertWritableRepo(); // fail out if read-only
* @param array $files List of files to delete
* @param int $flags Bitwise combination of the following flags:
* self::SKIP_LOCKING Skip any file locking when doing the deletions
- * @return FileRepoStatus
+ * @return Status
*/
public function cleanupBatch( array $files, $flags = 0 ) {
$this->assertWritableRepo(); // fail out if read-only
* @param array|string|null $options An array consisting of a key named headers
* listing extra headers. If a string, taken as content-disposition header.
* (Support for array of options new in 1.23)
- * @return FileRepoStatus
+ * @return Status
*/
final public function quickImport( $src, $dst, $options = null ) {
return $this->quickImportBatch( [ [ $src, $dst, $options ] ] );
* This is intended for purging thumbnails.
*
* @param string $path Virtual URL or storage path
- * @return FileRepoStatus
+ * @return Status
*/
final public function quickPurge( $path ) {
return $this->quickPurgeBatch( [ $path ] );
* When "headers" are given they are used as HTTP headers if supported.
*
* @param array $triples List of (source path or FSFile, destination path, disposition)
- * @return FileRepoStatus
+ * @return Status
*/
public function quickImportBatch( array $triples ) {
$status = $this->newGood();
* This does no locking nor journaling and is intended for purging thumbnails.
*
* @param array $paths List of virtual URLs or storage paths
- * @return FileRepoStatus
+ * @return Status
*/
public function quickPurgeBatch( array $paths ) {
$status = $this->newGood();
* @param string $originalName The base name of the file as specified
* by the user. The file extension will be maintained.
* @param string $srcPath The current location of the file.
- * @return FileRepoStatus Object with the URL in the value.
+ * @return Status Object with the URL in the value.
*/
public function storeTemp( $originalName, $srcPath ) {
$this->assertWritableRepo(); // fail out if read-only
* @param string $dstPath Target file system path
* @param int $flags Bitwise combination of the following flags:
* self::DELETE_SOURCE Delete the source files on success
- * @return FileRepoStatus
+ * @return Status
*/
public function concatenate( array $srcPaths, $dstPath, $flags = 0 ) {
$this->assertWritableRepo(); // fail out if read-only
* @param int $flags Bitfield, may be FileRepo::DELETE_SOURCE to indicate
* that the source file should be deleted if possible
* @param array $options Optional additional parameters
- * @return FileRepoStatus
+ * @return Status
*/
public function publish(
$src, $dstRel, $archiveRel, $flags = 0, array $options = []
* @param int $flags Bitfield, may be FileRepo::DELETE_SOURCE to indicate
* that the source files should be deleted if possible
* @throws MWException
- * @return FileRepoStatus
+ * @return Status
*/
public function publishBatch( array $ntuples, $flags = 0 ) {
$this->assertWritableRepo(); // fail out if read-only
$params = [ 'noAccess' => true, 'noListing' => true ] + $params;
}
- return $this->backend->prepare( $params );
+ $status = $this->newGood();
+ $status->merge( $this->backend->prepare( $params ) );
+
+ return $status;
}
/**
* @param mixed $srcRel Relative path for the file to be deleted
* @param mixed $archiveRel Relative path for the archive location.
* Relative to a private archive directory.
- * @return FileRepoStatus
+ * @return Status
*/
public function delete( $srcRel, $archiveRel ) {
$this->assertWritableRepo(); // fail out if read-only
* 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
+ * @return Status
*/
public function deleteBatch( array $sourceDestPairs ) {
$this->assertWritableRepo(); // fail out if read-only
$path = $this->resolveToStoragePath( $virtualUrl );
$params = [ 'src' => $path, 'headers' => $headers, 'options' => $optHeaders ];
- return $this->backend->streamFile( $params );
+ $status = $this->newGood();
+ $status->merge( $this->backend->streamFile( $params ) );
+
+ return $status;
}
/**
/** @var bool */
protected $hasSharedCache;
- # Other stuff
+ /** @var IDatabase */
protected $dbConn;
+
+ /** @var callable */
protected $fileFactory = [ 'ForeignDBFile', 'newFromTitle' ];
+ /** @var callable */
protected $fileFromRowFactory = [ 'ForeignDBFile', 'newFromRow' ];
/**
* @ingroup FileRepo
*/
class LocalRepo extends FileRepo {
- /** @var array */
+ /** @var callable */
protected $fileFactory = [ 'LocalFile', 'newFromTitle' ];
-
- /** @var array */
+ /** @var callable */
protected $fileFactoryKey = [ 'LocalFile', 'newFromKey' ];
-
- /** @var array */
+ /** @var callable */
protected $fileFromRowFactory = [ 'LocalFile', 'newFromRow' ];
-
- /** @var array */
+ /** @var callable */
protected $oldFileFromRowFactory = [ 'OldLocalFile', 'newFromRow' ];
-
- /** @var array */
+ /** @var callable */
protected $oldFileFactory = [ 'OldLocalFile', 'newFromTitle' ];
-
- /** @var array */
+ /** @var callable */
protected $oldFileFactoryKey = [ 'OldLocalFile', 'newFromKey' ];
function __construct( array $info = null ) {
parent::__construct( $info );
- $this->hasSha1Storage = isset( $info['storageLayout'] ) && $info['storageLayout'] === 'sha1';
+ $this->hasSha1Storage = isset( $info['storageLayout'] )
+ && $info['storageLayout'] === 'sha1';
if ( $this->hasSha1Storage() ) {
$this->backend = new FileBackendDBRepoWrapper( [
*
* @param array $storageKeys
*
- * @return FileRepoStatus
+ * @return Status
*/
function cleanupDeletedBatch( array $storageKeys ) {
if ( $this->hasSha1Storage() ) {
/**
* Get a connection to the replica DB
- * @return Database
+ * @return IDatabase
*/
function getSlaveDB() {
return wfGetDB( DB_REPLICA );
/**
* Get a connection to the master DB
- * @return Database
+ * @return IDatabase
*/
function getMasterDB() {
return wfGetDB( DB_MASTER );
*
* @param string $function
* @param array $args
- * @return FileRepoStatus
+ * @return Status
*/
protected function skipWriteOperationIfSha1( $function, array $args ) {
$this->assertWritableRepo(); // fail out if read-only
* @param int $flags A bitwise combination of:
* File::DELETE_SOURCE Delete the source file, i.e. move rather than copy
* @param array $options Optional additional parameters
- * @return FileRepoStatus On success, the value member contains the
+ * @return Status On success, the value member contains the
* archive name, or an empty string if it was a new file.
*
* STUB
* and logging are caller's responsibility
*
* @param Title $target New file name
- * @return FileRepoStatus
+ * @return Status
*/
function move( $target ) {
$this->readOnlyError();
* @param string $reason
* @param bool $suppress Hide content from sysops?
* @param User|null $user
- * @return FileRepoStatus
+ * @return Status
* STUB
* Overridden by LocalFile
*/
* @param string $srcPath
* @param int $flags
* @param array $options
- * @return FileRepoStatus
+ * @return Status
* @throws MWException
*/
function publish( $srcPath, $flags = 0, array $options = [] ) {
/**
* @param array $versions
* @param bool $unsuppress
- * @return FileRepoStatus
+ * @return Status
* @throws MWException
*/
function restore( $versions = [], $unsuppress = false ) {
* @param string $reason
* @param bool $suppress
* @param User|null $user
- * @return FileRepoStatus
+ * @return Status
* @throws MWException
*/
function delete( $reason, $suppress = false, $user = null ) {
/**
* @param Title $target
- * @return FileRepoStatus
+ * @return Status
* @throws MWException
*/
function move( $target ) {
* @param User|null $user User object or null to use $wgUser
* @param string[] $tags Change tags to add to the log entry and page revision.
* (This doesn't check $user's permissions.)
- * @return FileRepoStatus On success, the value member contains the
+ * @return Status On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
function upload( $src, $comment, $pageText, $flags = 0, $props = false,
* @param int $flags A bitwise combination of:
* File::DELETE_SOURCE Delete the source file, i.e. move rather than copy
* @param array $options Optional additional parameters
- * @return FileRepoStatus On success, the value member contains the
+ * @return Status On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
function publish( $src, $flags = 0, array $options = [] ) {
* @param int $flags A bitwise combination of:
* File::DELETE_SOURCE Delete the source file, i.e. move rather than copy
* @param array $options Optional additional parameters
- * @return FileRepoStatus On success, the value member contains the
+ * @return Status On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
function publishTo( $src, $dstRel, $flags = 0, array $options = [] ) {
* and logging are caller's responsibility
*
* @param Title $target New file name
- * @return FileRepoStatus
+ * @return Status
*/
function move( $target ) {
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
* @param string $reason
* @param bool $suppress
* @param User|null $user
- * @return FileRepoStatus
+ * @return Status
*/
function delete( $reason, $suppress = false, $user = null ) {
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
* @param bool $suppress
* @param User|null $user
* @throws MWException Exception on database or file store failure
- * @return FileRepoStatus
+ * @return Status
*/
function deleteOld( $archiveName, $reason, $suppress = false, $user = null ) {
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
* @param array $versions Set of record ids of deleted items to restore,
* or empty to restore all revisions.
* @param bool $unsuppress
- * @return FileRepoStatus
+ * @return Status
*/
function restore( $versions = [], $unsuppress = false ) {
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
/**
* Run the transaction
- * @return FileRepoStatus
+ * @return Status
*/
public function execute() {
$repo = $this->file->getRepo();
* rows and there's no need to keep the image row locked while it's acquiring those locks
* The caller may have its own transaction open.
* So we save the batch and let the caller call cleanup()
- * @return FileRepoStatus
+ * @return Status
*/
public function execute() {
/** @var Language */
/**
* Delete unused files in the deleted zone.
* This should be called from outside the transaction in which execute() was called.
- * @return FileRepoStatus
+ * @return Status
*/
public function cleanup() {
if ( !$this->cleanupBatch ) {
/**
* Perform the move.
- * @return FileRepoStatus
+ * @return Status
*/
public function execute() {
$repo = $this->file->repo;
* Verify the database updates and return a new FileRepoStatus indicating how
* many rows would be updated.
*
- * @return FileRepoStatus
+ * @return Status
*/
protected function verifyDBUpdates() {
$repo = $this->file->repo;
* @param string $timestamp
* @param string $comment
* @param User $user
- * @return FileRepoStatus
+ * @return Status
*/
function uploadOld( $srcPath, $archiveName, $timestamp, $comment, $user ) {
$this->lock();