Smuggli has submitted this change and it was merged.

Change subject: Improved caching
......................................................................


Improved caching

 * Invalidate settings cache directly after insertion not kinda additional in a 
hook

Change-Id: Ie3cb9508ebd0614a74e5ef136584d27f6be3405e
---
M BlueSpice.hooks.php
M includes/Config.class.php
M includes/utility/CacheHelper.class.php
3 files changed, 11 insertions(+), 19 deletions(-)

Approvals:
  Mglaser: Checked; Looks good to me, but someone else must approve
  Smuggli: Verified; Looks good to me, approved



diff --git a/BlueSpice.hooks.php b/BlueSpice.hooks.php
index d3f9342..6d6a654 100644
--- a/BlueSpice.hooks.php
+++ b/BlueSpice.hooks.php
@@ -15,7 +15,6 @@
 
 // START cache invalidation hooks
 $wgHooks['PageContentSaveComplete'][] = 
'BsCacheHelper::onPageContentSaveComplete';
-$wgHooks['BsSettingsAfterSaveSettings'][] = 
'BsCacheHelper::onBsSettingsAfterSaveSettings';
 // END cache invalidation hooks
 
 if ( !isset( $wgHooks['EditPage::showEditForm:initial'] ) ) {
diff --git a/includes/Config.class.php b/includes/Config.class.php
index d5916d7..da5a355 100644
--- a/includes/Config.class.php
+++ b/includes/Config.class.php
@@ -271,10 +271,10 @@
         * loads all settings from the database and saves the instances for 
every variable internal.
         */
        public static function loadSettings() {
-               $sKey = BsCacheHelper::getCacheKey( 'BlueSpice', 'BsConfig', 
'loadSettings' );
+               $sKey = BsCacheHelper::getCacheKey( 'BlueSpice', 'BsConfig', 
'settings' );
                $aData = BsCacheHelper::get( $sKey );
 
-               if( $aData !== false ) {
+               if ( $aData !== false ) {
                        wfDebugLog( 'BsMemcached' , __CLASS__.': Fetching 
settings from cache' );
                        $aRows = $aData;
                } else {
@@ -323,7 +323,7 @@
                        # if the setting is a boolean type then make sure, it
                        # gets saved as boolean type
                        if ( $setting->getOptions () & self::TYPE_BOOL ) {
-                               $value = ( bool ) $setting->getValue ();
+                               $value = (bool) $setting->getValue ();
                        } else {
                                $value = $setting->getValue ();
                        }
@@ -334,10 +334,17 @@
                        );
                }
 
-               # write the settings array to the database
                wfRunHooks( 'BsSettingsBeforeSaveSettings', array( &$aSettings 
) );
+
+               # write the settings array to the database
                $bReturn = $dbw->insert('bs_settings', $aSettings);
+
                wfRunHooks( 'BsSettingsAfterSaveSettings', array( $aSettings ) 
);
+
+               BsCacheHelper::invalidateCache(
+                       BsCacheHelper::getCacheKey( 'BlueSpice', 'BsConfig', 
'settings' )
+               );
+
                return $bReturn;
        }
 
diff --git a/includes/utility/CacheHelper.class.php 
b/includes/utility/CacheHelper.class.php
index 14f41d3..770c379 100644
--- a/includes/utility/CacheHelper.class.php
+++ b/includes/utility/CacheHelper.class.php
@@ -116,18 +116,4 @@
                return true;
        }
 
-       /**
-        * Invalidates bs settings cache
-        * @param type $aSettings
-        */
-       public static function onBsSettingsAfterSaveSettings( $aSettings ) {
-               $aKeys = array(
-                       BsCacheHelper::getCacheKey( 'BlueSpice', 'BsConfig', 
'loadSettings' )
-               );
-
-               BsCacheHelper::invalidateCache( $aKeys );
-
-               return true;
-       }
-
 }
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3cb9508ebd0614a74e5ef136584d27f6be3405e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Smuggli <mug...@hallowelt.biz>
Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz>
Gerrit-Reviewer: Pigpen <reym...@hallowelt.biz>
Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz>
Gerrit-Reviewer: Smuggli <mug...@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