Gilles has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/362199 )
Change subject: Make file purging also purge old versions
......................................................................
Make file purging also purge old versions
Also fixes purging for repos with sha1 thumb URLs.
Bug: T169198
Change-Id: Ibb98ecce83d690cc46769644038b54e37aea0b0d
---
M includes/filerepo/file/LocalFile.php
M includes/page/WikiFilePage.php
2 files changed, 19 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/99/362199/1
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index a412250..f71e1dc 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1032,9 +1032,15 @@
$purgeList = [];
foreach ( $files as $file ) {
- # Check that the base file name is part of the thumb
name
+ if ( $this->repo->supportsSha1URLs() ) {
+ $reference = $this->getSha1();
+ } else {
+ $reference = $this->getName();
+ }
+
+ # Check that the reference (filename or sha1) is part
of the thumb name
# This is a basic sanity check to avoid erasing
unrelated directories
- if ( strpos( $file, $this->getName() ) !== false
+ if ( strpos( $file, $reference ) !== false
|| strpos( $file, "-thumbnail" ) !== false //
"short" thumb name
) {
$purgeList[] = "{$dir}/{$file}";
diff --git a/includes/page/WikiFilePage.php b/includes/page/WikiFilePage.php
index 66fadf5..cf16f1a 100644
--- a/includes/page/WikiFilePage.php
+++ b/includes/page/WikiFilePage.php
@@ -173,13 +173,24 @@
if ( $this->mFile->exists() ) {
wfDebug( 'ImagePage::doPurge purging ' .
$this->mFile->getName() . "\n" );
DeferredUpdates::addUpdate( new HTMLCacheUpdate(
$this->mTitle, 'imagelinks' ) );
+ // Purge current version and its thumbnails
$this->mFile->purgeCache( [ 'forThumbRefresh' => true ]
);
+ // Purge the old versions and their thumbnails
+ foreach ( $this->mFile->getHistory() as $oldFile ) {
+ $oldFile->purgeCache( [ 'forThumbRefresh' =>
true ] );
+ }
} else {
wfDebug( 'ImagePage::doPurge no image for '
. $this->mFile->getName() . "; limiting purge
to cache only\n" );
// even if the file supposedly doesn't exist, force any
cached information
// to be updated (in case the cached information is
wrong)
+
+ // Purge current version and its thumbnails
$this->mFile->purgeCache( [ 'forThumbRefresh' => true ]
);
+ // Purge the old versions and their thumbnails
+ foreach ( $this->mFile->getHistory() as $oldFile ) {
+ $oldFile->purgeCache( [ 'forThumbRefresh' =>
true ] );
+ }
}
if ( $this->mRepo ) {
// Purge redirect cache
--
To view, visit https://gerrit.wikimedia.org/r/362199
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb98ecce83d690cc46769644038b54e37aea0b0d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits