From ede015209d4c24f0d48e7848fa37cc697cb7c404 Mon Sep 17 00:00:00 2001 From: Bryan Davis Date: Mon, 19 Aug 2013 18:11:44 +0000 Subject: [PATCH] Purge upstream caches when deleting file assets. Inform upstream caches when a file asset is deleted by calling SquidUpdate::purge(). This helps prevent unintentional information leakage in the event that the asset is being deleted for reasons of license or content. Bug: 51064 Change-Id: Ibf57e8f32d7dd04b8508a69706be5a40b49e5abd --- includes/filerepo/file/LocalFile.php | 16 ++++++++++++++++ includes/revisiondelete/RevisionDelete.php | 10 +++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 6e0769e48d..678a6ad27a 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1527,6 +1527,7 @@ class LocalFile extends File { * @return FileRepoStatus object. */ function delete( $reason, $suppress = false ) { + global $wgUseSquid; if ( $this->getRepo()->getReadOnlyReason() !== false ) { return $this->readOnlyFatalStatus(); } @@ -1549,6 +1550,15 @@ class LocalFile extends File { $this->purgeOldThumbnails( $archiveName ); } + if ( $wgUseSquid ) { + // Purge the squid + $purgeUrls = array(); + foreach ($archiveNames as $archiveName ) { + $purgeUrls[] = $this->getArchiveUrl( $archiveName ); + } + SquidUpdate::purge( $purgeUrls ); + } + return $status; } @@ -1567,6 +1577,7 @@ class LocalFile extends File { * @return FileRepoStatus object. */ function deleteOld( $archiveName, $reason, $suppress = false ) { + global $wgUseSquid; if ( $this->getRepo()->getReadOnlyReason() !== false ) { return $this->readOnlyFatalStatus(); } @@ -1584,6 +1595,11 @@ class LocalFile extends File { $this->purgeHistory(); } + if ( $wgUseSquid ) { + // Purge the squid + SquidUpdate::purge( array( $this->getArchiveUrl( $archiveName ) ) ); + } + return $status; } diff --git a/includes/revisiondelete/RevisionDelete.php b/includes/revisiondelete/RevisionDelete.php index 135e31ff67..191286d10d 100644 --- a/includes/revisiondelete/RevisionDelete.php +++ b/includes/revisiondelete/RevisionDelete.php @@ -498,11 +498,19 @@ class RevDel_FileList extends RevDel_List { } public function doPostCommitUpdates() { + global $wgUseSquid; $file = wfLocalFile( $this->title ); $file->purgeCache(); $file->purgeDescription(); + $purgeUrls = array(); foreach ( $this->ids as $timestamp ) { - $file->purgeOldThumbnails( $timestamp . '!' . $this->title->getDBkey() ); + $archiveName = $timestamp . '!' . $this->title->getDBkey(); + $file->purgeOldThumbnails( $archiveName ); + $purgeUrls[] = $file->getArchiveUrl( $archiveName ); + } + if ( $wgUseSquid ) { + // purge full images from cache + SquidUpdate::purge( $purgeUrls ); } return Status::newGood(); } -- 2.20.1