Merge "Remove wrong null type from @param of Content::fillParserOutput"
[lhc/web/wiklou.git] / includes / filerepo / file / LocalFile.php
index 300e68e..07f1f09 100644 (file)
@@ -49,10 +49,10 @@ class LocalFile extends File {
        /** @var bool Does the file exist on disk? (loadFromXxx) */
        protected $fileExists;
 
-       /** @var int image width */
+       /** @var int Image width */
        protected $width;
 
-       /** @var int image height */
+       /** @var int Image height */
        protected $height;
 
        /** @var int Returned by getimagesize (loadFromXxx) */
@@ -91,10 +91,10 @@ class LocalFile extends File {
        /** @var int Result of the query for the file's history (nextHistoryLine) */
        private $historyRes;
 
-       /** @var string Major mime type */
+       /** @var string Major MIME type */
        private $major_mime;
 
-       /** @var string Minor mime type */
+       /** @var string Minor MIME type */
        private $minor_mime;
 
        /** @var string Upload timestamp */
@@ -166,7 +166,7 @@ class LocalFile extends File {
         * Create a LocalFile from a SHA-1 key
         * Do not call this except from inside a repo class.
         *
-        * @param string $sha1 base-36 SHA-1
+        * @param string $sha1 Base-36 SHA-1
         * @param LocalRepo $repo
         * @param string|bool $timestamp MW_timestamp (optional)
         * @return bool|LocalFile
@@ -379,6 +379,7 @@ class LocalFile extends File {
 
        /**
         * Load file metadata from the DB
+        * @param int $flags
         */
        function loadFromDB( $flags = 0 ) {
                # Polymorphic function name to distinguish foreign and local fetches
@@ -437,7 +438,7 @@ class LocalFile extends File {
        /**
         * @param DatabaseBase $dbr
         * @param string $fname
-        * @return array|false
+        * @return array|bool
         */
        private function loadFieldsWithTimestamp( $dbr, $fname ) {
                $fieldMap = false;
@@ -594,6 +595,7 @@ class LocalFile extends File {
 
                # Don't destroy file info of missing files
                if ( !$this->fileExists ) {
+                       $this->unlock();
                        wfDebug( __METHOD__ . ": file does not exist, aborting\n" );
                        wfProfileOut( __METHOD__ );
 
@@ -604,6 +606,7 @@ class LocalFile extends File {
                list( $major, $minor ) = self::splitMime( $this->mime );
 
                if ( wfReadOnly() ) {
+                       $this->unlock();
                        wfProfileOut( __METHOD__ );
 
                        return;
@@ -782,7 +785,7 @@ class LocalFile extends File {
        }
 
        /**
-        * Returns the mime type of the file.
+        * Returns the MIME type of the file.
         * @return string
         */
        function getMimeType() {
@@ -831,7 +834,7 @@ class LocalFile extends File {
        /**
         * Get all thumbnail names previously generated for this file
         * @param string|bool $archiveName Name of an archive file, default false
-        * @return array first element is the base dir, then files in that base dir.
+        * @return array First element is the base dir, then files in that base dir.
         */
        function getThumbnails( $archiveName = false ) {
                if ( $archiveName ) {
@@ -929,6 +932,7 @@ class LocalFile extends File {
 
        /**
         * Delete cached transformed files for the current version only.
+        * @param array $options
         */
        function purgeThumbnails( $options = array() ) {
                global $wgUseSquid;
@@ -1266,6 +1270,7 @@ class LocalFile extends File {
                # Fail now if the file isn't there
                if ( !$this->fileExists ) {
                        wfDebug( __METHOD__ . ": File " . $this->getRel() . " went missing!\n" );
+                       $dbw->rollback( __METHOD__ );
                        wfProfileOut( __METHOD__ );
 
                        return false;
@@ -1845,7 +1850,7 @@ class LocalFile extends File {
         * Start a transaction and lock the image for update
         * Increments a reference counter if the lock is already held
         * @throws MWException Throws an error if the lock was not acquired
-        * @return bool success
+        * @return bool Success
         */
        function lock() {
                $dbw = $this->repo->getMasterDB();
@@ -2368,6 +2373,7 @@ class LocalFileRestoreBatch {
 
        /**
         * Add a file by ID
+        * @param int $fa_id
         */
        function addId( $fa_id ) {
                $this->ids[] = $fa_id;
@@ -2375,6 +2381,7 @@ class LocalFileRestoreBatch {
 
        /**
         * Add a whole lot of files by ID
+        * @param int[] $ids
         */
        function addIds( $ids ) {
                $this->ids = array_merge( $this->ids, $ids );
@@ -2829,6 +2836,7 @@ class LocalFileMoveBatch {
                // cleanupTarget() to trigger. It would delete the C files and cause data loss.
                $statusDb = $this->doDBUpdates();
                if ( !$statusDb->isGood() ) {
+                       $destFile->unlock();
                        $this->file->unlockAndRollback();
                        $statusDb->ok = false;
 
@@ -2846,6 +2854,7 @@ class LocalFileMoveBatch {
                if ( !$statusMove->isGood() ) {
                        // Delete any files copied over (while the destination is still locked)
                        $this->cleanupTarget( $triplets );
+                       $destFile->unlock();
                        $this->file->unlockAndRollback(); // unlocks the destination
                        wfDebugLog( 'imagemove', "Error in moving files: " . $statusMove->getWikiText() );
                        $statusMove->ok = false;
@@ -2968,6 +2977,7 @@ class LocalFileMoveBatch {
        /**
         * Cleanup a partially moved array of triplets by deleting the target
         * files. Called if something went wrong half way.
+        * @param array $triplets
         */
        function cleanupTarget( $triplets ) {
                // Create dest pairs from the triplets
@@ -2983,6 +2993,7 @@ class LocalFileMoveBatch {
        /**
         * Cleanup a fully moved array of triplets by deleting the source files.
         * Called at the end of the move process if everything else went ok.
+        * @param array $triplets
         */
        function cleanupSource( $triplets ) {
                // Create source file names from the triplets