Make use of \File::getArchiveRel to avoid code duplication
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 2 Jan 2019 15:24:56 +0000 (16:24 +0100)
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 2 Jan 2019 15:24:56 +0000 (16:24 +0100)
Before, the string "archive/" was hard-coded in many places.

Change-Id: I62e4471711d183f37e89dc02f3709187164faf0e

includes/filerepo/file/File.php
includes/filerepo/file/LocalFile.php
includes/filerepo/file/OldLocalFile.php

index bf09e08..cc39b94 100644 (file)
@@ -1586,7 +1586,7 @@ abstract class File implements IDBAccessObject {
         * @return string
         */
        function getArchiveThumbRel( $archiveName, $suffix = false ) {
-               $path = 'archive/' . $this->getHashPath() . $archiveName . "/";
+               $path = $this->getArchiveRel( $archiveName ) . "/";
                if ( $suffix === false ) {
                        $path = substr( $path, 0, -1 );
                } else {
index e4c2173..a8d1fb5 100644 (file)
@@ -1861,7 +1861,7 @@ class LocalFile extends File {
                $this->lock(); // begin
 
                $archiveName = wfTimestamp( TS_MW ) . '!' . $this->getName();
-               $archiveRel = 'archive/' . $this->getHashPath() . $archiveName;
+               $archiveRel = $this->getArchiveRel( $archiveName );
 
                if ( $repo->hasSha1Storage() ) {
                        $sha1 = $repo->isVirtualUrl( $srcPath )
index f103afa..ad95bb4 100644 (file)
@@ -325,14 +325,14 @@ class OldLocalFile extends LocalFile {
         * @return string
         */
        function getRel() {
-               return 'archive/' . $this->getHashPath() . $this->getArchiveName();
+               return $this->getArchiveRel( $this->getArchiveName() );
        }
 
        /**
         * @return string
         */
        function getUrlRel() {
-               return 'archive/' . $this->getHashPath() . rawurlencode( $this->getArchiveName() );
+               return $this->getArchiveRel( rawurlencode( $this->getArchiveName() ) );
        }
 
        function upgradeRow() {
@@ -416,7 +416,7 @@ class OldLocalFile extends LocalFile {
        function uploadOld( $srcPath, $archiveName, $timestamp, $comment, $user ) {
                $this->lock();
 
-               $dstRel = 'archive/' . $this->getHashPath() . $archiveName;
+               $dstRel = $this->getArchiveRel( $archiveName );
                $status = $this->publishTo( $srcPath, $dstRel );
 
                if ( $status->isGood() ) {