From be7423c52cadebdd4aab37a4959e57fadb9f2cf0 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 18 Jan 2019 13:03:45 -0800 Subject: [PATCH] filerepo: avoid dynamic calls to FileRepo::isVirtualUrl Change-Id: Ie851ec33ba5d7965393e41595d0b4b9df070bd27 --- includes/filerepo/file/LocalFile.php | 4 ++-- includes/upload/UploadBase.php | 2 +- includes/upload/UploadStash.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index f883dea122..878e82d032 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1320,7 +1320,7 @@ class LocalFile extends File { $srcPath = ( $src instanceof FSFile ) ? $src->getPath() : $src; if ( !$props ) { - if ( $this->repo->isVirtualUrl( $srcPath ) + if ( FileRepo::isVirtualUrl( $srcPath ) || FileBackend::isStoragePath( $srcPath ) ) { $props = $this->repo->getFileProps( $srcPath ); @@ -1863,7 +1863,7 @@ class LocalFile extends File { $archiveRel = $this->getArchiveRel( $archiveName ); if ( $repo->hasSha1Storage() ) { - $sha1 = $repo->isVirtualUrl( $srcPath ) + $sha1 = FileRepo::isVirtualUrl( $srcPath ) ? $repo->getFileSha1( $srcPath ) : FSFile::getSha1Base36FromPath( $srcPath ); /** @var FileBackendDBRepoWrapper $wrapperBackend */ diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index a579b69ccc..d9e8e99498 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -296,7 +296,7 @@ abstract class UploadBase { */ public function getRealPath( $srcPath ) { $repo = RepoGroup::singleton()->getLocalRepo(); - if ( $repo->isVirtualUrl( $srcPath ) ) { + if ( FileRepo::isVirtualUrl( $srcPath ) ) { /** @todo Just make uploads work with storage paths UploadFromStash * loads files via virtual URLs. */ diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index 8ddbd04686..babbe3aee1 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -599,7 +599,7 @@ class UploadStashFile extends UnregisteredLocalFile { $this->fileKey = $key; // resolve mwrepo:// urls - if ( $repo->isVirtualUrl( $path ) ) { + if ( FileRepo::isVirtualUrl( $path ) ) { $path = $repo->resolveVirtualUrl( $path ); } else { // check if path appears to be sane, no parent traversals, -- 2.20.1