Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/103645


Change subject: Fix ArticlePurge hook
......................................................................

Fix ArticlePurge hook

* Actually register the hook
* Hook will provide a WikiPage object, not an article
* Introduce HelpPages::purgeCache which actually clears the cache

Change-Id: If109114eb0ed1efa543452be09bea36f8501af43
---
M HelpPages.body.php
M HelpPages.hooks.php
M HelpPages.php
3 files changed, 11 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/HelpPages 
refs/changes/45/103645/1

diff --git a/HelpPages.body.php b/HelpPages.body.php
index aac3ef6..6c41876 100644
--- a/HelpPages.body.php
+++ b/HelpPages.body.php
@@ -31,6 +31,14 @@
        }
 
        /**
+        * @param Title $title
+        */
+       public static function purgeCache( Title $title ) {
+               global $wgMemc;
+               $wgMemc->delete( self::getCacheKey( $title->getPrefixedText() ) 
);
+       }
+
+       /**
         * Use action=parse to get rendered HTML of a page
         * @param $title string
         * @return array
diff --git a/HelpPages.hooks.php b/HelpPages.hooks.php
index 69d6138..29f2364 100644
--- a/HelpPages.hooks.php
+++ b/HelpPages.hooks.php
@@ -55,17 +55,13 @@
                return true;
        }
 
-
        /**
         * Use action=purge to clear cache
-        * @param $article Article
+        * @param WikiPage $article
         * @return bool
         */
        public static function onArticlePurge( &$article ) {
-               global $wgMemc;
-               $title = $article->getContext()->getTitle();
-               $key = HelpPages::getCacheKey( $title );
-               $wgMemc->delete( $key );
+               HelpPages::purgeCache( $article->getTitle() );
                return true;
        }
 }
diff --git a/HelpPages.php b/HelpPages.php
index 443014c..0d223a1 100644
--- a/HelpPages.php
+++ b/HelpPages.php
@@ -41,6 +41,7 @@
 
 $wgHooks['ShowMissingArticle'][] = 'HelpPagesHooks::onShowMissingArticle';
 $wgHooks['SkinTemplateNavigation::Universal'][] = 
'HelpPagesHooks::onSkinTemplateNavigationUniversal';
+$wgHooks['ArticlePurge'][] = 'HelpPagesHooks::onArticlePurge';
 
 $wgResourceModules['ext.HelpPages'] = array(
        'styles' => 'ext.HelpPages.css',

-- 
To view, visit https://gerrit.wikimedia.org/r/103645
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If109114eb0ed1efa543452be09bea36f8501af43
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/HelpPages
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to