* Purge thumbnails and metadata cache for action=purge on an image page
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 1 Mar 2006 01:27:36 +0000 (01:27 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 1 Mar 2006 01:27:36 +0000 (01:27 +0000)
RELEASE-NOTES
includes/Article.php
includes/ImagePage.php

index fed3043..cfc15e5 100644 (file)
@@ -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 ===
index aa2faa9..bfdb68d 100644 (file)
@@ -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.
index 24b0e48..dd5f4f7 100644 (file)
@@ -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();
+       }
 
 }