From d62e743e30d15baea6e1344ad87a9aa41f1fd316 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Fri, 17 Jun 2011 17:12:20 +0000 Subject: [PATCH] Fix r85635. Move LocalFile::publish() magic to LocalFile::publishTo() which has an explicit $destRel argument. --- includes/filerepo/LocalFile.php | 30 ++++++++++++++++++++---------- includes/filerepo/OldLocalFile.php | 8 +++++--- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index dd0e31583c..0e3bc65969 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -1043,20 +1043,30 @@ class LocalFile extends File { * @param $srcPath String: local filesystem path to the source image * @param $flags Integer: a bitwise combination of: * File::DELETE_SOURCE Delete the source file, i.e. move rather than copy - * @param $dstArchiveName string File name if the file is to be published - * into the archive * @return FileRepoStatus object. On success, the value member contains the * archive name, or an empty string if it was a new file. */ - function publish( $srcPath, $flags = 0, $dstArchiveName = null ) { - $this->lock(); + function publish( $srcPath, $flags = 0 ) { + return $this->publishTo( $srcPath, $this->getRel(), $flags ); + } - if ( $dstArchiveName ) { - $dstRel = 'archive/' . $this->getHashPath() . $dstArchiveName; - } else { - $dstRel = $this->getRel(); - } - + /** + * Move or copy a file to a specified location. Returns a FileRepoStatus + * object with the archive name in the "value" member on success. + * + * The archive name should be passed through to recordUpload for database + * registration. + * + * @param $srcPath String: local filesystem path to the source image + * @param $dstRel String: target relative path + * @param $flags Integer: a bitwise combination of: + * File::DELETE_SOURCE Delete the source file, i.e. move rather than copy + * @return FileRepoStatus object. On success, the value member contains the + * archive name, or an empty string if it was a new file. + */ + function publishTo( $srcPath, $dstRel, $flags = 0 ) { + $this->lock(); + $archiveName = wfTimestamp( TS_MW ) . '!'. $this->getName(); $archiveRel = 'archive/' . $this->getHashPath() . $archiveName; $flags = $flags & File::DELETE_SOURCE ? LocalRepo::DELETE_SOURCE : 0; diff --git a/includes/filerepo/OldLocalFile.php b/includes/filerepo/OldLocalFile.php index ba07e4fafd..1fb8c5626c 100644 --- a/includes/filerepo/OldLocalFile.php +++ b/includes/filerepo/OldLocalFile.php @@ -223,9 +223,11 @@ class OldLocalFile extends LocalFile { */ function uploadOld( $srcPath, $archiveName, $timestamp, $comment, $user, $flags = 0 ) { $this->lock(); - $status = $this->publish( $srcPath, - $flags & File::DELETE_SOURCE ? FileRepo::DELETE_SOURCE : 0, - $archiveName ); + + $dstRel = 'archive/' . $this->getHashPath() . $archiveName; + $status = $this->publishTo( $srcPath, $dstRel, + $flags & File::DELETE_SOURCE ? FileRepo::DELETE_SOURCE : 0 + ); if ( $status->isGood() ) { if ( !$this->recordOldUpload( $srcPath, $archiveName, $timestamp, $comment, $user ) ) { -- 2.20.1