From 327f9654d04ce2e217aec07996f6a4bcecf0366e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 1 Mar 2006 01:27:36 +0000 Subject: [PATCH] * Purge thumbnails and metadata cache for action=purge on an image page --- RELEASE-NOTES | 1 + includes/Article.php | 41 +++++++++++++++++++++++++++-------------- includes/ImagePage.php | 16 ++++++++++++++++ 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fed3043abd..cfc15e570d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -668,6 +668,7 @@ fully support the editing toolbar, but was found to be too confusing. "-resize 100x35!"; some thumbs were off due to differences in rounding and would be generated smaller than expected. * (bug 5062) Width sometimes one pixel short when using maximum heights +* Purge thumbnails and metadata cache for action=purge on an image page === Caveats === diff --git a/includes/Article.php b/includes/Article.php index aa2faa9294..bfdb68ddb6 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -978,23 +978,16 @@ class Article { $this->view(); } + /** + * Handle action=purge + */ function purge() { - global $wgUser, $wgRequest, $wgOut, $wgUseSquid; - - if ( $wgUser->isLoggedIn() || $wgRequest->wasPosted() || ! wfRunHooks( 'ArticlePurge', array( &$this ) ) ) { - // Invalidate the cache - $this->mTitle->invalidateCache(); - - if ( $wgUseSquid ) { - // Commit the transaction before the purge is sent - $dbw = wfGetDB( DB_MASTER ); - $dbw->immediateCommit(); + global $wgUser, $wgRequest, $wgOut; - // Send purge - $update = SquidUpdate::newSimplePurge( $this->mTitle ); - $update->doUpdate(); + if ( $wgUser->isLoggedIn() || $wgRequest->wasPosted() ) { + if( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) { + $this->doPurge(); } - $this->view(); } else { $msg = $wgOut->parse( wfMsg( 'confirm_purge' ) ); $action = $this->mTitle->escapeLocalURL( 'action=purge' ); @@ -1009,6 +1002,26 @@ class Article { $wgOut->addHTML( $msg ); } } + + /** + * Perform the actions of a page purging + */ + function doPurge() { + global $wgUseSquid; + // Invalidate the cache + $this->mTitle->invalidateCache(); + + if ( $wgUseSquid ) { + // Commit the transaction before the purge is sent + $dbw = wfGetDB( DB_MASTER ); + $dbw->immediateCommit(); + + // Send purge + $update = SquidUpdate::newSimplePurge( $this->mTitle ); + $update->doUpdate(); + } + $this->view(); + } /** * Insert a new empty page record for this article. diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 24b0e48ca3..dd5f4f7755 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -664,6 +664,22 @@ END $edit = new EditPage( $this ); return $edit->blockedIPpage(); } + + /** + * Override handling of action=purge + */ + function doPurge() { + $this->img = new Image( $this->mTitle ); + if( $this->img->exists() ) { + wfDebug( "ImagePage::doPurge purging " . $this->img->getName() . "\n" ); + $linksTo = $this->img->getLinksTo(); + Title::touchArray( $linksTo ); + $this->img->purgeCache(); + } else { + wfDebug( "ImagePage::doPurge no image\n" ); + } + parent::doPurge(); + } } -- 2.20.1