r113312 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113311‎ | r113312 | r113313 >
Date:22:46, 7 March 2012
Author:aaron
Status:ok
Tags:
Comment:
[FileRepo]
* Made upload() explicitly check $status->successCount rather than isOk() as FileRepo::publish() gives fatal statuses where it used to only give warnings. This way, failed uploads still displace the current image DB row to oldimage rather than do nothing and have the same image row point to a new file (which can cause mismatched metadata).
* Disabled exception about invalid oi_archive_name. This makes things more broken in that when people get this an error on upload (which happens when the FS has no current file but the DB does), the new file is added as the current version in the FS but the DB is unchanged. Thus, the metadata can be mismatched.
Modified paths:
  • /trunk/phase3/includes/filerepo/file/LocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/file/LocalFile.php
@@ -915,7 +915,10 @@
916916 $this->lock(); // begin
917917 $status = $this->publish( $srcPath, $flags );
918918
919 - if ( $status->ok ) {
 919+ if ( $status->successCount > 0 ) {
 920+ # Essentially we are displacing any existing current file and saving
 921+ # a new current file at the old location. If just the first succeeded,
 922+ # we still need to displace the current DB entry and put in a new one.
920923 if ( !$this->recordUpload2( $status->value, $comment, $pageText, $props, $timestamp, $user ) ) {
921924 $status->fatal( 'filenotfound', $srcPath );
922925 }
@@ -1014,8 +1017,12 @@
10151018 );
10161019
10171020 if ( $dbw->affectedRows() == 0 ) {
1018 - if ( $oldver == '' ) {
1019 - throw new MWException( "Empty oi_archive_name. Database and storage out of sync?" );
 1021+ if ( $oldver == '' ) { // XXX
 1022+ # (bug 34993) publish() can displace the current file and yet fail to save
 1023+ # a new one. The next publish attempt will treat the file as a brand new file
 1024+ # and pass an empty $oldver. Allow this bogus value so we can displace the
 1025+ # `image` row to `oldimage`, leaving room for the new current file `image` row.
 1026+ #throw new MWException( "Empty oi_archive_name. Database and storage out of sync?" );
10201027 }
10211028 $reupload = true;
10221029 # Collision, this is an update of a file

Follow-up revisions

RevisionCommit summaryAuthorDate
r113315Fix for r113312: explain the bug without the use of commented-out codetstarling23:00, 7 March 2012
r113319MFT r113312aaron23:04, 7 March 2012
r114015MFT r112918, r113214, r113268, r113277, r113312, r113415, r113454, r113737, r...reedy15:18, 16 March 2012

Status & tagging log