jenkins-bot has submitted this change and it was merged.
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, 25 insertions(+), 1 deletion(-)
Approvals:
Brian Wolff: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index 6e0769e..678a6ad 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1527,6 +1527,7 @@
* @return FileRepoStatus object.
*/
function delete( $reason, $suppress = false ) {
+ global $wgUseSquid;
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
}
@@ -1549,6 +1550,15 @@
$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 @@
* @return FileRepoStatus object.
*/
function deleteOld( $archiveName, $reason, $suppress = false ) {
+ global $wgUseSquid;
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
}
@@ -1584,6 +1595,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 135e31f..191286d 100644
--- a/includes/revisiondelete/RevisionDelete.php
+++ b/includes/revisiondelete/RevisionDelete.php
@@ -498,11 +498,19 @@
}
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();
}
--
To view, visit https://gerrit.wikimedia.org/r/79842
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibf57e8f32d7dd04b8508a69706be5a40b49e5abd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits