From: Thiemo Kreuz Date: Wed, 2 Jan 2019 15:24:56 +0000 (+0100) Subject: Make use of \File::getArchiveRel to avoid code duplication X-Git-Tag: 1.34.0-rc.0~3159^2~2 X-Git-Url: http://git.cyclocoop.org/data/%7BGarradin/WEBSITE%7D?a=commitdiff_plain;h=2181f406ead57c296f85257ac299cf20f17d857f;p=lhc%2Fweb%2Fwiklou.git Make use of \File::getArchiveRel to avoid code duplication Before, the string "archive/" was hard-coded in many places. Change-Id: I62e4471711d183f37e89dc02f3709187164faf0e --- diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index bf09e0820e..cc39b94475 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -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 { diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index e4c2173664..a8d1fb5459 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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 ) diff --git a/includes/filerepo/file/OldLocalFile.php b/includes/filerepo/file/OldLocalFile.php index f103afabc6..ad95bb4210 100644 --- a/includes/filerepo/file/OldLocalFile.php +++ b/includes/filerepo/file/OldLocalFile.php @@ -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() ) {