From: Aaron Date: Fri, 20 Apr 2012 19:32:39 +0000 (-0700) Subject: Bug 34934: allow moving files with rows with bad oi_archive_name values. X-Git-Tag: 1.31.0-rc.0~23862^2 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=6f7ee691edafd18c0524ca1b02aa6a1b434aaba0;p=lhc%2Fweb%2Fwiklou.git Bug 34934: allow moving files with rows with bad oi_archive_name values. Note that delete/restore already work in such cases. Change-Id: I6b98b219b548203c4677f5be6f703585ac2cd027 --- diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index af1b7cd999..ffadca9f20 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -2319,7 +2319,8 @@ class LocalFileMoveBatch { 'oldimage', array( 'oi_name' => $this->newName, - 'oi_archive_name = ' . $dbw->strreplace( 'oi_archive_name', $dbw->addQuotes( $this->oldName ), $dbw->addQuotes( $this->newName ) ), + 'oi_archive_name = ' . $dbw->strreplace( 'oi_archive_name', + $dbw->addQuotes( $this->oldName ), $dbw->addQuotes( $this->newName ) ), ), array( 'oi_name' => $this->oldName ), __METHOD__ @@ -2328,7 +2329,10 @@ class LocalFileMoveBatch { $affected = $dbw->affectedRows(); $total = $this->oldCount; $status->successCount += $affected; - $status->failCount += $total - $affected; + // Bug 34934: $total is based on files that actually exist. + // There may be more DB rows than such files, in which case $affected + // can be greater than $total. We use max() to avoid negatives here. + $status->failCount += max( 0, $total - $affected ); if ( $status->failCount ) { $status->error( 'imageinvalidfilename' ); }