$this->lock(); // begin
$batch->addCurrent();
- $batch->addOlds();
+ $archiveNames = $batch->addOlds();
$status = $batch->execute();
$this->unlock(); // done
wfDebugLog( 'imagemove', "Finished moving {$this->name}" );
$this->purgeEverything();
+ foreach ( $archiveNames as $archiveName ) {
+ $this->purgeOldThumbnails( $archiveName );
+ }
if ( $status->isOK() ) {
// Now switch the object
$this->title = $target;
return $this->readOnlyFatalStatus();
}
- $dbw = $this->repo->getMasterDB();
$batch = new LocalFileDeleteBatch( $this, $reason, $suppress );
- $archiveNames = array();
$this->lock(); // begin
$batch->addCurrent();
# Get old version relative paths
- $result = $dbw->select( 'oldimage',
- array( 'oi_archive_name' ),
- array( 'oi_name' => $this->getName() ) );
- foreach ( $result as $row ) {
- $batch->addOld( $row->oi_archive_name );
- $archiveNames[] = $row->oi_archive_name;
- }
+ $archiveNames = $batch->addOlds();
$status = $batch->execute();
if ( $status->isOK() ) {
// Update site_stats
+ $dbw = $this->repo->getMasterDB();
$site_stats = $dbw->tableName( 'site_stats' );
$dbw->query( "UPDATE $site_stats SET ss_images=ss_images-1", __METHOD__ );
}
return $this->readOnlyFatalStatus();
}
- $this->lock(); // begin
-
$batch = new LocalFileDeleteBatch( $this, $reason, $suppress );
+
+ $this->lock(); // begin
$batch->addOld( $archiveName );
- $this->purgeOldThumbnails( $archiveName );
$status = $batch->execute();
-
$this->unlock(); // done
+ $this->purgeOldThumbnails( $archiveName );
if ( $status->isOK() ) {
$this->purgeDescription();
$this->purgeHistory();
$this->archiveUrls[] = $this->file->getArchiveUrl( $oldName );
}
+ /**
+ * Add the old versions of the image to the batch
+ * @return Array List of archive names from old versions
+ */
+ function addOlds() {
+ $archiveNames = array();
+
+ $dbw = $this->file->repo->getMasterDB();
+ $result = $dbw->select( 'oldimage',
+ array( 'oi_archive_name' ),
+ array( 'oi_name' => $this->file->getName() ),
+ __METHOD__
+ );
+
+ foreach ( $result as $row ) {
+ $this->addOld( $row->oi_archive_name );
+ $archiveNames[] = $row->oi_archive_name;
+ }
+
+ return $archiveNames;
+ }
+
function getOldRels() {
if ( !isset( $this->srcRels['.'] ) ) {
$oldRels =& $this->srcRels;
return $this->status;
}
- // Purge squid
- if ( $wgUseSquid ) {
- $urls = array();
-
- foreach ( $this->srcRels as $srcRel ) {
- $urlRel = str_replace( '%2F', '/', rawurlencode( $srcRel ) );
- $urls[] = $this->file->repo->getZoneUrl( 'public' ) . '/' . $urlRel;
- }
- SquidUpdate::purge( $urls );
- }
-
// Delete image/oldimage rows
$this->doDBDeletes();
/**
* Add the old versions of the image to the batch
+ * @return Array List of archive names from old versions
*/
function addOlds() {
$archiveBase = 'archive';
$this->olds = array();
$this->oldCount = 0;
+ $archiveNames = array();
$result = $this->db->select( 'oldimage',
array( 'oi_archive_name', 'oi_deleted' ),
);
foreach ( $result as $row ) {
+ $archiveNames[] = $row->oi_archive_name;
$oldName = $row->oi_archive_name;
$bits = explode( '!', $oldName, 2 );
"{$archiveBase}/{$this->newHash}{$timestamp}!{$this->newName}"
);
}
+
+ return $archiveNames;
}
/**
function execute() {
$repo = $this->file->repo;
$status = $repo->newGood();
- $triplets = $this->getMoveTriplets();
+ $triplets = $this->getMoveTriplets();
$triplets = $this->removeNonexistentFiles( $triplets );
// Copy the files into their new location