Merge "Set visibility on class properties in LocalFile.php"
[lhc/web/wiklou.git] / includes / filerepo / file / LocalFile.php
index d94bbad..191642f 100644 (file)
@@ -46,44 +46,81 @@ define( 'MW_FILE_VERSION', 9 );
 class LocalFile extends File {
        const CACHE_FIELD_MAX_LEN = 1000;
 
-       /**#@+
-        * @private
-        */
-       var
-               $fileExists,       # does the file exist on disk? (loadFromXxx)
-               $historyLine,      # Number of line to return by nextHistoryLine() (constructor)
-               $historyRes,       # result of the query for the file's history (nextHistoryLine)
-               $width,            # \
-               $height,           #  |
-               $bits,             #   --- returned by getimagesize (loadFromXxx)
-               $attr,             # /
-               $media_type,       # MEDIATYPE_xxx (bitmap, drawing, audio...)
-               $mime,             # MIME type, determined by MimeMagic::guessMimeType
-               $major_mime,       # Major mime type
-               $minor_mime,       # Minor mime type
-               $size,             # Size in bytes (loadFromXxx)
-               $metadata,         # Handler-specific metadata
-               $timestamp,        # Upload timestamp
-               $sha1,             # SHA-1 base 36 content hash
-               $user, $user_text, # User, who uploaded the file
-               $description,      # Description of current revision of the file
-               $dataLoaded,       # Whether or not core data has been loaded from the database (loadFromXxx)
-               $extraDataLoaded,  # Whether or not lazy-loaded data has been loaded from the database
-               $upgraded,         # Whether the row was upgraded on load
-               $locked,           # True if the image row is locked
-               $lockedOwnTrx,     # True if the image row is locked with a lock initiated transaction
-               $missing,          # True if file is not present in file system. Not to be cached in memcached
-               $deleted;          # Bitfield akin to rev_deleted
-
-       /**#@-*/
-
-       /**
-        * @var LocalRepo
-        */
-       var $repo;
+       /** @var bool Does the file exist on disk? (loadFromXxx) */
+       protected $fileExists;
 
+       /** @var int image width */
+       protected $width;
+
+       /** @var int image height */
+       protected $height;
+
+       /** @var int Returned by getimagesize (loadFromXxx) */
+       protected $bits;
+
+       /** @var string MEDIATYPE_xxx (bitmap, drawing, audio...) */
+       protected $media_type;
+
+       /** @var string MIME type, determined by MimeMagic::guessMimeType */
+       protected $mime;
+
+       /** @var int Size in bytes (loadFromXxx) */
+       protected $size;
+
+       /** @var string Handler-specific metadata */
+       protected $metadata;
+
+       /** @var string SHA-1 base 36 content hash */
+       protected $sha1;
+
+       /** @var bool Whether or not core data has been loaded from the database (loadFromXxx) */
+       protected $dataLoaded;
+
+       /** @var bool Whether or not lazy-loaded data has been loaded from the database */
+       protected $extraDataLoaded;
+
+       /** @var int Bitfield akin to rev_deleted */
+       protected $deleted;
+
+       /** @var string */
        protected $repoClass = 'LocalRepo';
 
+       /** @var int Number of line to return by nextHistoryLine() (constructor) */
+       private $historyLine;
+
+       /** @var int Result of the query for the file's history (nextHistoryLine) */
+       private $historyRes;
+
+       /** @var string Major mime type */
+       private $major_mime;
+
+       /** @var string Minor mime type */
+       private $minor_mime;
+
+       /** @var string Upload timestamp */
+       private $timestamp;
+
+       /** @var int User ID of uploader */
+       private $user;
+
+       /** @var string User name of uploader */
+       private $user_text;
+
+       /** @var string Description of current revision of the file */
+       private $description;
+
+       /** @var bool Whether the row was upgraded on load */
+       private $upgraded;
+
+       /** @var bool True if the image row is locked */
+       private $locked;
+
+       /** @var bool True if the image row is locked with a lock initiated transaction */
+       private $lockedOwnTrx;
+
+       /** @var bool True if file is not present in file system. Not to be cached in memcached */
+       private $missing;
+
        const LOAD_ALL = 1; // integer; load all the lazy fields too (like metadata)
 
        /**
@@ -291,7 +328,8 @@ class LocalFile extends File {
         */
        function getCacheFields( $prefix = 'img_' ) {
                static $fields = array( 'size', 'width', 'height', 'bits', 'media_type',
-                       'major_mime', 'minor_mime', 'metadata', 'timestamp', 'sha1', 'user', 'user_text', 'description' );
+                       'major_mime', 'minor_mime', 'metadata', 'timestamp', 'sha1', 'user',
+                       'user_text', 'description' );
                static $results = array();
 
                if ( $prefix == '' ) {
@@ -993,11 +1031,7 @@ class LocalFile extends File {
                $r = array();
 
                foreach ( $res as $row ) {
-                       if ( $this->repo->oldFileFromRowFactory ) {
-                               $r[] = call_user_func( $this->repo->oldFileFromRowFactory, $row, $this->repo );
-                       } else {
-                               $r[] = OldLocalFile::newFromRow( $row, $this->repo );
-                       }
+                       $r[] = $this->repo->newFileFromRow( $row );
                }
 
                if ( $order == 'ASC' ) {
@@ -1090,7 +1124,9 @@ class LocalFile extends File {
         * @return FileRepoStatus object. On success, the value member contains the
         *     archive name, or an empty string if it was a new file.
         */
-       function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false, $timestamp = false, $user = null ) {
+       function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false,
+               $timestamp = false, $user = null
+       ) {
                global $wgContLang;
 
                if ( $this->getRepo()->getReadOnlyReason() !== false ) {
@@ -1369,7 +1405,13 @@ class LocalFile extends File {
                        # There's already a log entry, so don't make a second RC entry
                        # Squid and file cache for the description page are purged by doEditContent.
                        $content = ContentHandler::makeContent( $pageText, $descTitle );
-                       $status = $wikiPage->doEditContent( $content, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user );
+                       $status = $wikiPage->doEditContent(
+                               $content,
+                               $comment,
+                               EDIT_NEW | EDIT_SUPPRESS_RC,
+                               false,
+                               $user
+                       );
 
                        $dbw->begin( __METHOD__ ); // XXX; doEdit() uses a transaction
                        // Now that the page exists, make an RC entry.
@@ -1847,13 +1889,26 @@ class LocalFile extends File {
  */
 class LocalFileDeleteBatch {
 
-       /**
-        * @var LocalFile
-        */
-       var $file;
+       /** @var LocalFile */
+       private $file;
 
-       var $reason, $srcRels = array(), $archiveUrls = array(), $deletionBatch, $suppress;
-       var $status;
+       /** @var string */
+       private $reason;
+
+       /** @var array */
+       private $srcRels = array();
+
+       /** @var array */
+       private $archiveUrls = array();
+
+       /** @var array Items to be processed in the deletion batch */
+       private $deletionBatch;
+
+       /** @var bool Wether to suppress all suppressable fields when deleting */
+       private $suppress;
+
+       /** @var FileRepoStatus */
+       private $status;
 
        /**
         * @param $file File
@@ -2192,12 +2247,20 @@ class LocalFileDeleteBatch {
  * @ingroup FileAbstraction
  */
 class LocalFileRestoreBatch {
-       /**
-        * @var LocalFile
-        */
-       var $file;
+       /** @var LocalFile */
+       private $file;
+
+       /** @var array List of file IDs to restore */
+       private $cleanupBatch;
+
+       /** @var array List of file IDs to restore */
+       private $ids;
 
-       var $cleanupBatch, $ids, $all, $unsuppress = false;
+       /** @var bool Add all revisions of the file  */
+       private $all;
+
+       /** @var bool Wether to remove all settings for suppressed fields  */
+       private $unsuppress = false;
 
        /**
         * @param $file File
@@ -2291,7 +2354,8 @@ class LocalFileRestoreBatch {
                                continue;
                        }
 
-                       $deletedRel = $this->file->repo->getDeletedHashPath( $row->fa_storage_key ) . $row->fa_storage_key;
+                       $deletedRel = $this->file->repo->getDeletedHashPath( $row->fa_storage_key ) .
+                               $row->fa_storage_key;
                        $deletedUrl = $this->file->repo->getVirtualUrl() . '/deleted/' . $deletedRel;
 
                        if ( isset( $row->fa_sha1 ) ) {
@@ -2557,23 +2621,28 @@ class LocalFileRestoreBatch {
  * @ingroup FileAbstraction
  */
 class LocalFileMoveBatch {
+       /** @var LocalFile */
+       protected $file;
 
-       /**
-        * @var LocalFile
-        */
-       var $file;
+       /** @var Title */
+       protected $target;
 
-       /**
-        * @var Title
-        */
-       var $target;
+       /** @var   */
+       protected $cur;
+
+       /** @var   */
+       protected $olds;
 
-       var $cur, $olds, $oldCount, $archive;
+       /** @var   */
+       protected $oldCount;
+
+       /** @var   */
+       protected $archive;
 
        /**
         * @var DatabaseBase
         */
-       var $db;
+       protected $db;
 
        /**
         * @param File $file
@@ -2671,13 +2740,15 @@ class LocalFileMoveBatch {
 
                        return $statusDb;
                }
-               wfDebugLog( 'imagemove', "Renamed {$this->file->getName()} in database: {$statusDb->successCount} successes, {$statusDb->failCount} failures" );
+               wfDebugLog( 'imagemove', "Renamed {$this->file->getName()} in database: " .
+                       "{$statusDb->successCount} successes, {$statusDb->failCount} failures" );
 
                // Copy the files into their new location.
                // If a prior process fataled copying or cleaning up files we tolerate any
                // of the existing files if they are identical to the ones being stored.
                $statusMove = $repo->storeBatch( $triplets, FileRepo::OVERWRITE_SAME );
-               wfDebugLog( 'imagemove', "Moved files for {$this->file->getName()}: {$statusMove->successCount} successes, {$statusMove->failCount} failures" );
+               wfDebugLog( 'imagemove', "Moved files for {$this->file->getName()}: " .
+                       "{$statusMove->successCount} successes, {$statusMove->failCount} failures" );
                if ( !$statusMove->isGood() ) {
                        // Delete any files copied over (while the destination is still locked)
                        $this->cleanupTarget( $triplets );
@@ -2764,7 +2835,10 @@ class LocalFileMoveBatch {
                        // $move: (oldRelativePath, newRelativePath)
                        $srcUrl = $this->file->repo->getVirtualUrl() . '/public/' . rawurlencode( $move[0] );
                        $triplets[] = array( $srcUrl, 'public', $move[1] );
-                       wfDebugLog( 'imagemove', "Generated move triplet for {$this->file->getName()}: {$srcUrl} :: public :: {$move[1]}" );
+                       wfDebugLog(
+                               'imagemove',
+                               "Generated move triplet for {$this->file->getName()}: {$srcUrl} :: public :: {$move[1]}"
+                       );
                }
 
                return $triplets;