Fix LocalFile::move
authorGergő Tisza <tgr.huwiki@gmail.com>
Tue, 25 Jun 2019 14:30:31 +0000 (16:30 +0200)
committerGergő Tisza <tgr.huwiki@gmail.com>
Tue, 25 Jun 2019 16:38:13 +0000 (18:38 +0200)
Fixes a wfFindFile/wfLocalFile mixup in I9437494d.

Also restore the original behavior in Linker::makeBrokenImageLinkObj
for paranoia - findFile has a local cache so calling it and then
discarding the results is not completely a noop.

Bug: T226448
Change-Id: Ibb9d6f6383eb96ba27e0edd60423552e5cea4688

includes/Linker.php
includes/filerepo/file/LocalFile.php

index 1980154..01f695a 100644 (file)
@@ -688,8 +688,8 @@ class Linker {
                        $label = $title->getPrefixedText();
                }
                $encLabel = htmlspecialchars( $label );
-               $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
-               $currentExists = $time ? ( $file != false ) : false;
+               $currentExists = $time
+                       && MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title ) !== false;
 
                if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads )
                        && !$currentExists
index 1e1bde3..d7d6bf7 100644 (file)
@@ -1906,7 +1906,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();
                }
@@ -1923,8 +1923,8 @@ 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 );
+               $oldTitleFile = $localRepo->newFile( $this->title );
+               $newTitleFile = $localRepo->newFile( $target );
                // To avoid slow purges in the transaction, move them outside...
                DeferredUpdates::addUpdate(
                        new AutoCommitUpdate(