BryanDavis has uploaded a new change for review.
https://gerrit.wikimedia.org/r/79843
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/43/79843/1
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index 639228b..4f50bfa 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1484,6 +1484,7 @@
* @return FileRepoStatus object.
*/
function delete( $reason, $suppress = false ) {
+ global $wgUseSquid;
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
}
@@ -1506,6 +1507,15 @@
$this->purgeOldThumbnails( $archiveName );
}
+ if ( $wgUseSquid ) {
+ // Purge the squid
+ $purgeUrls = array();
+ foreach ($archiveNames as $archiveName ) {
+ $purgeUrls[] = $this->getArchiveUrl(
$archiveName );
+ }
+ SquidUpdate::purge( $purgeUrls );
+ }
+
return $status;
}
@@ -1524,6 +1534,7 @@
* @return FileRepoStatus object.
*/
function deleteOld( $archiveName, $reason, $suppress = false ) {
+ global $wgUseSquid;
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
}
@@ -1541,6 +1552,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 1ace383..f4c0796 100644
--- a/includes/revisiondelete/RevisionDelete.php
+++ b/includes/revisiondelete/RevisionDelete.php
@@ -499,9 +499,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/79843
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_21
Gerrit-Owner: BryanDavis <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits