https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113312
Revision: 113312 Author: aaron Date: 2012-03-07 22:46:47 +0000 (Wed, 07 Mar 2012) Log Message: ----------- [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: trunk/phase3/includes/filerepo/file/LocalFile.php =================================================================== --- trunk/phase3/includes/filerepo/file/LocalFile.php 2012-03-07 22:34:08 UTC (rev 113311) +++ trunk/phase3/includes/filerepo/file/LocalFile.php 2012-03-07 22:46:47 UTC (rev 113312) @@ -915,7 +915,10 @@ $this->lock(); // begin $status = $this->publish( $srcPath, $flags ); - if ( $status->ok ) { + if ( $status->successCount > 0 ) { + # Essentially we are displacing any existing current file and saving + # a new current file at the old location. If just the first succeeded, + # we still need to displace the current DB entry and put in a new one. if ( !$this->recordUpload2( $status->value, $comment, $pageText, $props, $timestamp, $user ) ) { $status->fatal( 'filenotfound', $srcPath ); } @@ -1014,8 +1017,12 @@ ); if ( $dbw->affectedRows() == 0 ) { - if ( $oldver == '' ) { - throw new MWException( "Empty oi_archive_name. Database and storage out of sync?" ); + if ( $oldver == '' ) { // XXX + # (bug 34993) publish() can displace the current file and yet fail to save + # a new one. The next publish attempt will treat the file as a brand new file + # and pass an empty $oldver. Allow this bogus value so we can displace the + # `image` row to `oldimage`, leaving room for the new current file `image` row. + #throw new MWException( "Empty oi_archive_name. Database and storage out of sync?" ); } $reupload = true; # Collision, this is an update of a file _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs