BryanDavis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/79844


Change subject: Purge upstream caches when deleting file assets.
......................................................................

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
---
M includes/filerepo/file/LocalFile.php
M includes/revisiondelete/RevisionDelete.php
2 files changed, 27 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/44/79844/1

diff --git a/includes/filerepo/file/LocalFile.php 
b/includes/filerepo/file/LocalFile.php
index 0f8b475..97cb9d9 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1242,6 +1242,7 @@
         * @return FileRepoStatus object.
         */
        function delete( $reason, $suppress = false ) {
+               global $wgUseSquid;
                $this->lock(); // begin
 
                $batch = new LocalFileDeleteBatch( $this, $reason, $suppress );
@@ -1267,6 +1268,15 @@
 
                $this->unlock(); // done
 
+               if ( $wgUseSquid ) {
+                       // Purge the squid
+                       $purgeUrls = array();
+                       foreach ($archiveNames as $archiveName ) {
+                               $purgeUrls[] = $this->getArchiveUrl( 
$archiveName );
+                       }
+                       SquidUpdate::purge( $purgeUrls );
+               }
+
                return $status;
        }
 
@@ -1285,6 +1295,7 @@
         * @return FileRepoStatus object.
         */
        function deleteOld( $archiveName, $reason, $suppress = false ) {
+               global $wgUseSquid;
                $this->lock(); // begin
 
                $batch = new LocalFileDeleteBatch( $this, $reason, $suppress );
@@ -1299,6 +1310,11 @@
                        $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 6cee624..ee91585 100644
--- a/includes/revisiondelete/RevisionDelete.php
+++ b/includes/revisiondelete/RevisionDelete.php
@@ -465,9 +465,20 @@
        }
 
        public function doPostCommitUpdates() {
+               global $wgUseSquid;
                $file = wfLocalFile( $this->title );
                $file->purgeCache();
                $file->purgeDescription();
+               $purgeUrls = array();
+               foreach ( $this->ids as $timestamp ) {
+                       $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();
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/79844
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf57e8f32d7dd04b8508a69706be5a40b49e5abd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_19
Gerrit-Owner: BryanDavis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to