From: jeroendedauw Date: Fri, 6 Jul 2012 11:27:23 +0000 (+0200) Subject: Always save the cache if stuff was added to it - dont require deriving class to call... X-Git-Tag: 1.31.0-rc.0~22826^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=25b1a5360b9b2ca3e7d89727266f429a794b260d;p=lhc%2Fweb%2Fwiklou.git Always save the cache if stuff was added to it - dont require deriving class to call save Change-Id: Ifd57c4c3f3d10be97080c9aae5599f6057ea9baf --- diff --git a/includes/specials/SpecialCachedPage.php b/includes/specials/SpecialCachedPage.php index 32eb2e751e..f5e1134d9a 100644 --- a/includes/specials/SpecialCachedPage.php +++ b/includes/specials/SpecialCachedPage.php @@ -56,6 +56,19 @@ abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper { */ protected $cacheEnabled = true; + /** + * Gets called after @see SpecialPage::execute. + * + * @since 1.20 + * + * @param $subPage string|null + */ + protected function afterExecute( $subPage ) { + $this->saveCache(); + + parent::afterExecute( $subPage ); + } + /** * Sets if the cache should be enabled or not. * @@ -76,21 +89,23 @@ abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper { * @param boolean|null $cacheEnabled Sets if the cache should be enabled or not. */ public function startCache( $cacheExpiry = null, $cacheEnabled = null ) { - $this->cacheHelper = new CacheHelper(); + if ( !isset( $this->cacheHelper ) ) { + $this->cacheHelper = new CacheHelper(); - $this->cacheHelper->setCacheEnabled( $this->cacheEnabled ); - $this->cacheHelper->setOnInitializedHandler( array( $this, 'onCacheInitialized' ) ); + $this->cacheHelper->setCacheEnabled( $this->cacheEnabled ); + $this->cacheHelper->setOnInitializedHandler( array( $this, 'onCacheInitialized' ) ); - $keyArgs = $this->getCacheKey(); + $keyArgs = $this->getCacheKey(); - if ( array_key_exists( 'action', $keyArgs ) && $keyArgs['action'] === 'purge' ) { - unset( $keyArgs['action'] ); - } + if ( array_key_exists( 'action', $keyArgs ) && $keyArgs['action'] === 'purge' ) { + unset( $keyArgs['action'] ); + } - $this->cacheHelper->setCacheKey( $keyArgs ); + $this->cacheHelper->setCacheKey( $keyArgs ); - if ( $this->getRequest()->getText( 'action' ) === 'purge' ) { - $this->cacheHelper->rebuildOnDemand(); + if ( $this->getRequest()->getText( 'action' ) === 'purge' ) { + $this->cacheHelper->rebuildOnDemand(); + } } $this->cacheHelper->startCache( $cacheExpiry, $cacheEnabled );