* Fix oi_deleted issues with image moving
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 3 May 2008 14:45:06 +0000 (14:45 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 3 May 2008 14:45:06 +0000 (14:45 +0000)
* Fix filearchive update status check

includes/filerepo/LocalFile.php

index 3409c34..094cd7c 100644 (file)
@@ -1646,7 +1646,7 @@ class LocalFileRestoreBatch {
  * Helper class for file movement
  */
 class LocalFileMoveBatch {
-       var $file, $cur, $olds, $archive, $thumbs, $target, $db;
+       var $file, $cur, $olds, $oldcount, $archive, $thumbs, $target, $db;
 
        function __construct( File $file, Title $target, Database $db ) {
                $this->file = $file;
@@ -1693,9 +1693,10 @@ class LocalFileMoveBatch {
        function addOlds() {
                $archiveBase = 'archive';
                $this->olds = array();
+               $this->oldcount = 0;
 
                $result = $this->db->select( 'oldimage',
-                       array( 'oi_archive_name' ),
+                       array( 'oi_archive_name', 'oi_deleted' ),
                        array( 'oi_name' => $this->oldName ),
                        __METHOD__
                );
@@ -1711,6 +1712,10 @@ class LocalFileMoveBatch {
                                wfDebug( 'Invalid old file name:' . $oldName );
                                continue;
                        }
+                       $this->oldcount++;
+                       if( $row->oi_deleted & File::DELETED_FILE ) {
+                               continue;
+                       }
                        $this->olds[] = array(
                                "{$archiveBase}/{$this->oldHash}{$oldname}",
                                "{$archiveBase}/{$this->oldHash}{$timestamp}!{$this->newName}"
@@ -1763,7 +1768,7 @@ class LocalFileMoveBatch {
                        __METHOD__
                );
                $affected = $dbw->affectedRows();
-               $total = count( $this->olds );
+               $total = $this->oldcount;
                $status->successCount += $affected;
                $status->failCount += $total - $affected;
 
@@ -1778,9 +1783,7 @@ class LocalFileMoveBatch {
                        __METHOD__
                );
                $affected = $dbw->affectedRows();
-               $total = count( $this->olds );
                $status->successCount += $affected;
-               $status->failCount += $total - $affected;
 
                return $status;
        }