r90296 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90295‎ | r90296 | r90297 >
Date:17:12, 17 June 2011
Author:btongminh
Status:ok (Comments)
Tags:
Comment:
Fix r85635. Move LocalFile::publish() magic to LocalFile::publishTo() which has an explicit $destRel argument.
Modified paths:
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/OldLocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/OldLocalFile.php
@@ -223,10 +223,12 @@
224224 */
225225 function uploadOld( $srcPath, $archiveName, $timestamp, $comment, $user, $flags = 0 ) {
226226 $this->lock();
227 - $status = $this->publish( $srcPath,
228 - $flags & File::DELETE_SOURCE ? FileRepo::DELETE_SOURCE : 0,
229 - $archiveName );
230227
 228+ $dstRel = 'archive/' . $this->getHashPath() . $archiveName;
 229+ $status = $this->publishTo( $srcPath, $dstRel,
 230+ $flags & File::DELETE_SOURCE ? FileRepo::DELETE_SOURCE : 0
 231+ );
 232+
231233 if ( $status->isGood() ) {
232234 if ( !$this->recordOldUpload( $srcPath, $archiveName, $timestamp, $comment, $user ) ) {
233235 $status->fatal( 'filenotfound', $srcPath );
Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -1043,20 +1043,30 @@
10441044 * @param $srcPath String: local filesystem path to the source image
10451045 * @param $flags Integer: a bitwise combination of:
10461046 * File::DELETE_SOURCE Delete the source file, i.e. move rather than copy
1047 - * @param $dstArchiveName string File name if the file is to be published
1048 - * into the archive
10491047 * @return FileRepoStatus object. On success, the value member contains the
10501048 * archive name, or an empty string if it was a new file.
10511049 */
1052 - function publish( $srcPath, $flags = 0, $dstArchiveName = null ) {
 1050+ function publish( $srcPath, $flags = 0 ) {
 1051+ return $this->publishTo( $srcPath, $this->getRel(), $flags );
 1052+ }
 1053+
 1054+ /**
 1055+ * Move or copy a file to a specified location. Returns a FileRepoStatus
 1056+ * object with the archive name in the "value" member on success.
 1057+ *
 1058+ * The archive name should be passed through to recordUpload for database
 1059+ * registration.
 1060+ *
 1061+ * @param $srcPath String: local filesystem path to the source image
 1062+ * @param $dstRel String: target relative path
 1063+ * @param $flags Integer: a bitwise combination of:
 1064+ * File::DELETE_SOURCE Delete the source file, i.e. move rather than copy
 1065+ * @return FileRepoStatus object. On success, the value member contains the
 1066+ * archive name, or an empty string if it was a new file.
 1067+ */
 1068+ function publishTo( $srcPath, $dstRel, $flags = 0 ) {
10531069 $this->lock();
1054 -
1055 - if ( $dstArchiveName ) {
1056 - $dstRel = 'archive/' . $this->getHashPath() . $dstArchiveName;
1057 - } else {
1058 - $dstRel = $this->getRel();
1059 - }
1060 -
 1070+
10611071 $archiveName = wfTimestamp( TS_MW ) . '!'. $this->getName();
10621072 $archiveRel = 'archive/' . $this->getHashPath() . $archiveName;
10631073 $flags = $flags & File::DELETE_SOURCE ? LocalRepo::DELETE_SOURCE : 0;

Follow-up revisions

RevisionCommit summaryAuthorDate
r92434MFT to REL1_18...hashar15:05, 18 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85635First part of bug 22881: Allow uploading directly into the archive to support...btongminh20:19, 7 April 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   23:15, 21 June 2011

Looks ok. Wouldn't hurt to add an import/export test suite to confirm, but as that's destructive it's not in the current top-tier testing stuff.

Status & tagging log