filerepo: Avoid two pointless substr() in File
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 2 Jan 2019 15:27:09 +0000 (16:27 +0100)
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 2 Jan 2019 15:27:09 +0000 (16:27 +0100)
In both cases the slash was added one line above, just to be cut off
again.

Change-Id: I15ff6b47821033f123f555f02c42fc8984ad9800

includes/filerepo/file/File.php

index cc39b94..76bdba4 100644 (file)
@@ -1586,11 +1586,9 @@ abstract class File implements IDBAccessObject {
         * @return string
         */
        function getArchiveThumbRel( $archiveName, $suffix = false ) {
-               $path = $this->getArchiveRel( $archiveName ) . "/";
-               if ( $suffix === false ) {
-                       $path = substr( $path, 0, -1 );
-               } else {
-                       $path .= $suffix;
+               $path = $this->getArchiveRel( $archiveName );
+               if ( $suffix !== false ) {
+                       $path .= '/' . $suffix;
                }
 
                return $path;
@@ -1676,11 +1674,9 @@ abstract class File implements IDBAccessObject {
                $this->assertRepoDefined();
                $ext = $this->getExtension();
                $path = $this->repo->getZoneUrl( 'thumb', $ext ) . '/archive/' .
-                       $this->getHashPath() . rawurlencode( $archiveName ) . "/";
-               if ( $suffix === false ) {
-                       $path = substr( $path, 0, -1 );
-               } else {
-                       $path .= rawurlencode( $suffix );
+                       $this->getHashPath() . rawurlencode( $archiveName );
+               if ( $suffix !== false ) {
+                       $path .= '/' . rawurlencode( $suffix );
                }
 
                return $path;