From: Antoine Musso Date: Thu, 10 Nov 2011 11:56:52 +0000 (+0000) Subject: move store writing out of recache() X-Git-Tag: 1.31.0-rc.0~26596 X-Git-Url: http://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=7e9f50387f52c3ccfd8870ab5b2bf470764b8695;p=lhc%2Fweb%2Fwiklou.git move store writing out of recache() Writing to cache is now handled in a new method. That makes recache() a bit shorter and easier to read. Since there is no point in writing data to /dev/null , return early in such a case (ie if store is LCStore_Null). --- diff --git a/includes/LocalisationCache.php b/includes/LocalisationCache.php index ad707dc18a..ffea229e7f 100644 --- a/includes/LocalisationCache.php +++ b/includes/LocalisationCache.php @@ -710,6 +710,28 @@ class LocalisationCache { $this->loadedItems[$code][$key] = true; } + # Write data to the persistant store + $this->saveLangInStore( $code, $data ); + + wfProfileOut( __METHOD__ ); + } + + /** + * Helper for recache() this is not mean to be called outside of recache() + * When the localisation store is null (LCStore_Null), method does nothing. + * + * @param $code String: language code to save data for + * @param $data Array: language data forged by recache() + */ + protected function saveLangInStore( $code, $data ) { + wfProfileIn( __METHOD__ ); + + if( $this->store instanceof LCStore_Null ) { + # No point in saving data to /dev/null + wfProfileOut( __METHOD__ ); + return; + } + # Save to the persistent cache $this->store->startWrite( $code ); foreach ( $allData as $key => $value ) { @@ -724,11 +746,7 @@ class LocalisationCache { $this->store->finishWrite(); # Clear out the MessageBlobStore - # HACK: If using a null (i.e. disabled) storage backend, we - # can't write to the MessageBlobStore either - if ( !$this->store instanceof LCStore_Null ) { - MessageBlobStore::clear(); - } + MessageBlobStore::clear(); wfProfileOut( __METHOD__ ); } @@ -1186,4 +1204,4 @@ class LocalisationCache_BulkLoad extends LocalisationCache { $this->unload( $code ); } } -} \ No newline at end of file +}