jenkins-bot has submitted this change and it was merged.

Change subject: BSFoundation: ArticleHelper - Added cache invalidation
......................................................................


BSFoundation: ArticleHelper - Added cache invalidation

* Added invalidation onPageContentSaveComplete
* Removed cache for page props, due to the fact, that the db select still 
returns the magicwords after they have been removed from article

Change-Id: I18c0c3a38afaac6dbc39b40c90bf77dd139cf751
---
M extension.json
M includes/CoreHooks.php
M includes/utility/ArticleHelper.class.php
3 files changed, 55 insertions(+), 24 deletions(-)

Approvals:
  Robert Vogel: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 5dab669..bddd268 100644
--- a/extension.json
+++ b/extension.json
@@ -83,7 +83,8 @@
                "SkinAfterContent": "BsCoreHooks::onSkinAfterContent",
                "ParserFirstCallInit": "BsCoreHooks::onParserFirstCallInit",
                "UserAddGroup": "BsGroupHelper::addTemporaryGroupToUserHelper",
-               "ExtensionTypes": "BsCoreHooks::onExtensionTypes"
+               "ExtensionTypes": "BsCoreHooks::onExtensionTypes",
+               "PageContentSaveComplete": 
"BsCoreHooks::onPageContentSaveComplete"
        },
        "config": {
                "BlueSpiceExtInfo": {
diff --git a/includes/CoreHooks.php b/includes/CoreHooks.php
index 5253574..6dbaebe 100755
--- a/includes/CoreHooks.php
+++ b/includes/CoreHooks.php
@@ -669,4 +669,23 @@
                $out->addJsConfigVars( 'bsgTestSystem',$bsgTestSystem );
        }
 
+       /**
+        * Used for invalidations
+        * @param WikiPage $article
+        * @param User $user
+        * @param Content $content
+        * @param string $summary
+        * @param boolean $isMinor
+        * @param $isWatch deprecated
+        * @param $section deprecated
+        * @param integer $flags
+        * @param {Revision|null} $revision
+        * @param Status $status
+        * @param integer $baseRevId
+        */
+       public static function onPageContentSaveComplete( $article, $user, 
$content, $summary, $isMinor, $isWatch, $section, $flags, $revision, $status, 
$baseRevId ) {
+               BsArticleHelper::getInstance( $article->getTitle() 
)->invalidate();
+               return true;
+       }
+
 }
diff --git a/includes/utility/ArticleHelper.class.php 
b/includes/utility/ArticleHelper.class.php
index 9dc06fc..4c6a611 100644
--- a/includes/utility/ArticleHelper.class.php
+++ b/includes/utility/ArticleHelper.class.php
@@ -128,30 +128,23 @@
         * Fetches the page_props table
         */
        public function loadPageProps() {
-               $iArticleId = $this->oTitle->getArticleID();
-
-               $sKey = BsCacheHelper::getCacheKey( 'BlueSpice', 
'ArticleHelper', 'loadPageProps', $iArticleId );
-               $aData = BsCacheHelper::get( $sKey );
-
-               if( $aData !== false ) {
-                       wfDebugLog( 'BsMemcached', __CLASS__.': Fetching page 
props from cache' );
-                       $this->aPageProps = $aData;
-               } else {
-                       wfDebugLog( 'BsMemcached', __CLASS__.': Fetching page 
props from DB' );
-                       $dbr = wfGetDB( DB_SLAVE );
-                       $res = $dbr->select(
-                               'page_props',
-                               array('pp_propname', 'pp_value'),
-                               array('pp_page' => $iArticleId ),
-                               __METHOD__
-                       );
-
-                       foreach( $res as $row ) {
-                               $this->aPageProps[$row->pp_propname] = 
$row->pp_value;
-                       }
-                       BsCacheHelper::set( $sKey, $this->aPageProps, 60*15 
);// invalidates cache after 15 minutes
-               }
                $this->bIsLoaded = true;
+               $this->aPageProps = array();
+               if( !$this->oTitle->exists() ) {
+                       return;
+               }
+
+               $dbr = wfGetDB( DB_SLAVE );
+               $res = $dbr->select(
+                       'page_props',
+                       array('pp_propname', 'pp_value'),
+                       array( 'pp_page' => $this->oTitle->getArticleID() ),
+                       __METHOD__
+               );
+
+               foreach( $res as $row ) {
+                       $this->aPageProps[$row->pp_propname] = $row->pp_value;
+               }
        }
 
        /**
@@ -166,4 +159,22 @@
                return $oWikiPage->getRedirectTarget();
        }
 
+       public function invalidate() {
+               $this->bIsLoaded = false;
+               $this->aPageProps = array();
+
+               if( !$this->oTitle->exists() ) {
+                       return true;
+               }
+
+               $sKey = BsCacheHelper::getCacheKey(
+                       'BlueSpice',
+                       'ArticleHelper',
+                       'getDiscussionAmount',
+                       $this->oTitle->getTalkPage()->getArticleID()
+               );
+
+               BsCacheHelper::invalidateCache( $sKey );
+       }
+
 }
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I18c0c3a38afaac6dbc39b40c90bf77dd139cf751
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Pwirth <wi...@hallowelt.biz>
Gerrit-Reviewer: Dvogel hallowelt <daniel.vo...@hallowelt.com>
Gerrit-Reviewer: Ljonka <l.verhovs...@gmail.com>
Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz>
Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to