X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Ffilerepo%2FFileRepo.php;h=0e4b2f0b50eb6189aad5194a1b0cf39dbac5f329;hb=1a2299c74908501bd2b21bc5129d68737aaef004;hp=1a6c8180ef6c8db73e5343ec4f17e1a2a948be68;hpb=3d653e8ab542e502f4dcf574c9e4917cf56a5f8c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 1a6c8180ef..0e4b2f0b50 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -99,7 +99,7 @@ class FileRepo { */ protected $pathDisclosureProtection = 'simple'; - /** @var bool Public zone URL. */ + /** @var string|false Public zone URL. */ protected $url; /** @var string The base thumbnail URL. Defaults to "/thumb". */ @@ -309,7 +309,7 @@ class FileRepo { * @return bool Whether non-ASCII path characters are allowed */ public function backendSupportsUnicodePaths() { - return ( $this->getBackend()->getFeatures() & FileBackend::ATTR_UNICODE_PATHS ); + return (bool)( $this->getBackend()->getFeatures() & FileBackend::ATTR_UNICODE_PATHS ); } /** @@ -393,7 +393,7 @@ class FileRepo { 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 ); @@ -737,7 +737,7 @@ class FileRepo { * constructor, whereas local repositories use the local Title functions. * * @param string $name - * @return string + * @return string|false */ public function getDescriptionUrl( $name ) { $encName = wfUrlencode( $name ); @@ -771,7 +771,7 @@ class FileRepo { * * @param string $name Name of image to fetch * @param string $lang Language to fetch it in, if any. - * @return string + * @return string|false */ public function getDescriptionRenderUrl( $name, $lang = null ) { $query = 'action=render'; @@ -818,7 +818,7 @@ class FileRepo { * 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 @@ -841,7 +841,7 @@ class FileRepo { * 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 @@ -912,7 +912,7 @@ class FileRepo { * @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 @@ -952,7 +952,7 @@ class FileRepo { * @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 ] ] ); @@ -964,7 +964,7 @@ class FileRepo { * 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 ] ); @@ -995,7 +995,7 @@ class FileRepo { * 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(); @@ -1040,7 +1040,7 @@ class FileRepo { * 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(); @@ -1059,13 +1059,13 @@ class FileRepo { /** * Pick a random name in the temp zone and store a file to it. - * Returns a FileRepoStatus object with the file Virtual URL in the value, + * Returns a Status object with the file Virtual URL in the value, * file can later be disposed using FileRepo::freeTemp(). * * @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 @@ -1107,7 +1107,7 @@ class FileRepo { * @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 @@ -1143,7 +1143,7 @@ class FileRepo { * Copy or move a file either from a storage path, virtual URL, * or file system path, into this repository at the specified destination location. * - * Returns a FileRepoStatus object. On success, the value contains "new" or + * Returns a Status object. On success, the value contains "new" or * "archived", to indicate whether the file was new with that name. * * Options to $options include: @@ -1156,7 +1156,7 @@ class FileRepo { * @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 = [] @@ -1185,7 +1185,7 @@ class FileRepo { * @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 @@ -1322,7 +1322,10 @@ class FileRepo { $params = [ 'noAccess' => true, 'noListing' => true ] + $params; } - return $this->backend->prepare( $params ); + $status = $this->newGood(); + $status->merge( $this->backend->prepare( $params ) ); + + return $status; } /** @@ -1380,7 +1383,7 @@ class FileRepo { * @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 @@ -1403,7 +1406,7 @@ class FileRepo { * 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 @@ -1599,7 +1602,10 @@ class FileRepo { $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; } /** @@ -1918,12 +1924,3 @@ class FileRepo { return $this->supportsSha1URLs; } } - -/** - * FileRepo for temporary files created via FileRepo::getTempRepo() - */ -class TempFileRepo extends FileRepo { - public function getTempRepo() { - throw new MWException( "Cannot get a temp repo from a temp repo." ); - } -}