Merge "Make Special:ChangeContentModel field labels consistently use colons"
[lhc/web/wiklou.git] / includes / filerepo / file / LocalFile.php
index 1e1bde3..f3116e2 100644 (file)
@@ -25,6 +25,7 @@ use Wikimedia\AtEase\AtEase;
 use MediaWiki\Logger\LoggerFactory;
 use Wikimedia\Rdbms\Database;
 use Wikimedia\Rdbms\IDatabase;
+use Wikimedia\Rdbms\IResultWrapper;
 use MediaWiki\MediaWikiServices;
 
 /**
@@ -99,7 +100,7 @@ class LocalFile extends File {
        /** @var int Number of line to return by nextHistoryLine() (constructor) */
        private $historyLine;
 
-       /** @var int Result of the query for the file's history (nextHistoryLine) */
+       /** @var IResultWrapper|null Result of the query for the file's history (nextHistoryLine) */
        private $historyRes;
 
        /** @var string Major MIME type */
@@ -1906,7 +1907,7 @@ class LocalFile extends File {
         * @return Status
         */
        function move( $target ) {
-               $localRepo = MediaWikiServices::getInstance()->getRepoGroup();
+               $localRepo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
                if ( $this->getRepo()->getReadOnlyReason() !== false ) {
                        return $this->readOnlyFatalStatus();
                }
@@ -1922,10 +1923,9 @@ class LocalFile extends File {
 
                wfDebugLog( 'imagemove', "Finished moving {$this->name}" );
 
-               // Purge the source and target files...
-               $oldTitleFile = $localRepo->findFile( $this->title );
-               $newTitleFile = $localRepo->findFile( $target );
-               // To avoid slow purges in the transaction, move them outside...
+               // Purge the source and target files outside the transaction...
+               $oldTitleFile = $localRepo->newFile( $this->title );
+               $newTitleFile = $localRepo->newFile( $target );
                DeferredUpdates::addUpdate(
                        new AutoCommitUpdate(
                                $this->getRepo()->getMasterDB(),
@@ -1933,6 +1933,7 @@ class LocalFile extends File {
                                function () use ( $oldTitleFile, $newTitleFile, $archiveNames ) {
                                        $oldTitleFile->purgeEverything();
                                        foreach ( $archiveNames as $archiveName ) {
+                                               /** @var OldLocalFile $oldTitleFile */
                                                $oldTitleFile->purgeOldThumbnails( $archiveName );
                                        }
                                        $newTitleFile->purgeEverything();
@@ -1945,8 +1946,8 @@ class LocalFile extends File {
                        // Now switch the object
                        $this->title = $target;
                        // Force regeneration of the name and hashpath
-                       unset( $this->name );
-                       unset( $this->hashPath );
+                       $this->name = null;
+                       $this->hashPath = null;
                }
 
                return $status;