summaryrefslogtreecommitdiff
path: root/includes/filebackend/FSFile.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /includes/filebackend/FSFile.php
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/filebackend/FSFile.php')
-rw-r--r--includes/filebackend/FSFile.php38
1 files changed, 23 insertions, 15 deletions
diff --git a/includes/filebackend/FSFile.php b/includes/filebackend/FSFile.php
index 8f0a1334..1659c62a 100644
--- a/includes/filebackend/FSFile.php
+++ b/includes/filebackend/FSFile.php
@@ -27,26 +27,25 @@
* @ingroup FileBackend
*/
class FSFile {
- protected $path; // path to file
- protected $sha1Base36; // file SHA-1 in base 36
+ /** @var string Path to file */
+ protected $path;
+
+ /** @var string File SHA-1 in base 36 */
+ protected $sha1Base36;
/**
* Sets up the file object
*
* @param string $path Path to temporary file on local disk
- * @throws MWException
*/
public function __construct( $path ) {
- if ( FileBackend::isStoragePath( $path ) ) {
- throw new MWException( __METHOD__ . " given storage path `$path`." );
- }
$this->path = $path;
}
/**
* Returns the file system path
*
- * @return String
+ * @return string
*/
public function getPath() {
return $this->path;
@@ -82,6 +81,7 @@ class FSFile {
if ( $timestamp !== false ) {
$timestamp = wfTimestamp( TS_MW, $timestamp );
}
+
return $timestamp;
}
@@ -98,7 +98,7 @@ class FSFile {
* Get an associative array containing information about
* a file with the given storage path.
*
- * @param Mixed $ext: the file extension, or true to extract it from the filename.
+ * @param string|bool $ext The file extension, or true to extract it from the filename.
* Set it to false to ignore the extension.
*
* @return array
@@ -118,9 +118,9 @@ class FSFile {
$ext = self::extensionFromPath( $this->path );
}
- # mime type according to file contents
+ # MIME type according to file contents
$info['file-mime'] = $this->getMimeType();
- # logical mime type
+ # logical MIME type
$info['mime'] = $magic->improveTypeFromExtension( $info['file-mime'], $ext );
list( $info['major_mime'], $info['minor_mime'] ) = File::splitMime( $info['mime'] );
@@ -147,13 +147,14 @@ class FSFile {
}
wfProfileOut( __METHOD__ );
+
return $info;
}
/**
* Placeholder file properties to use for files that don't exist
*
- * @return Array
+ * @return array
*/
public static function placeholderProps() {
$info = array();
@@ -165,6 +166,7 @@ class FSFile {
$info['width'] = 0;
$info['height'] = 0;
$info['bits'] = 0;
+
return $info;
}
@@ -172,7 +174,7 @@ class FSFile {
* Exract image size information
*
* @param array $gis
- * @return Array
+ * @return array
*/
protected function extractImageSizeInfo( array $gis ) {
$info = array();
@@ -184,6 +186,7 @@ class FSFile {
} else {
$info['bits'] = 0;
}
+
return $info;
}
@@ -202,6 +205,7 @@ class FSFile {
if ( $this->sha1Base36 !== null && !$recache ) {
wfProfileOut( __METHOD__ );
+
return $this->sha1Base36;
}
@@ -214,6 +218,7 @@ class FSFile {
}
wfProfileOut( __METHOD__ );
+
return $this->sha1Base36;
}
@@ -225,19 +230,21 @@ class FSFile {
*/
public static function extensionFromPath( $path ) {
$i = strrpos( $path, '.' );
+
return strtolower( $i ? substr( $path, $i + 1 ) : '' );
}
/**
* Get an associative array containing information about a file in the local filesystem.
*
- * @param string $path absolute local filesystem path
- * @param Mixed $ext: the file extension, or true to extract it from the filename.
- * Set it to false to ignore the extension.
+ * @param string $path Absolute local filesystem path
+ * @param string|bool $ext The file extension, or true to extract it from the filename.
+ * Set it to false to ignore the extension.
* @return array
*/
public static function getPropsFromPath( $path, $ext = true ) {
$fsFile = new self( $path );
+
return $fsFile->getProps( $ext );
}
@@ -253,6 +260,7 @@ class FSFile {
*/
public static function getSha1Base36FromPath( $path ) {
$fsFile = new self( $path );
+
return $fsFile->getSha1Base36();
}
}