Do not create new archive file names for old files
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Wed, 2 Jan 2019 14:34:59 +0000 (15:34 +0100)
committerMarostegui <marostegui@wikimedia.org>
Thu, 21 Mar 2019 10:25:21 +0000 (10:25 +0000)
commit039b07d49c476fef7f5497bd35ce1cfc89d5ae16
treed7200b905b6d0679a1a994cef281f80ff86eced9
parenteb60a75635a0062100d973a1d30c4db6b9470060
Do not create new archive file names for old files

When importing a previously archived file revision, \OldLocalFile::uploadOld()
calls \LocalFile::publishTo() with $dstRel pointing to a location in the
archive. It does not make sense to create a new archive file name for a file
that is already in the archive. Instead, use the existing archive file name.

* Note how $archiveName is not used in the code below, except as part of the
  returned status.
* $archiveRel ends in \FileRepo::publishBatch(), but is barely used there
  except for (again) the status.
* \FileRepo::publishBatch() makes use of the dirname() extracted from
  $archiveRel. This patch does not make changes to this path, only to the
  file name.

This is the most trivial patch we could think of to fix the bug that the
return value is not the documented one ("On success, the value member
contains the archive name").

This will be covered by the test introduced in I15fad26.

Bug: T200001
Bug: T210755
Change-Id: I28b782e9b41ed78ac1674111094335849e15ba49
includes/filerepo/file/LocalFile.php