r102640 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102639‎ | r102640 | r102641 >
Date:11:56, 10 November 2011
Author:hashar
Status:reverted (Comments)
Tags:
Comment:
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).
Modified paths:
  • /trunk/phase3/includes/LocalisationCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LocalisationCache.php
@@ -710,6 +710,28 @@
711711 $this->loadedItems[$code][$key] = true;
712712 }
713713
 714+ # Write data to the persistant store
 715+ $this->saveLangInStore( $code, $data );
 716+
 717+ wfProfileOut( __METHOD__ );
 718+ }
 719+
 720+ /**
 721+ * Helper for recache() this is not mean to be called outside of recache()
 722+ * When the localisation store is null (LCStore_Null), method does nothing.
 723+ *
 724+ * @param $code String: language code to save data for
 725+ * @param $data Array: language data forged by recache()
 726+ */
 727+ protected function saveLangInStore( $code, $data ) {
 728+ wfProfileIn( __METHOD__ );
 729+
 730+ if( $this->store instanceof LCStore_Null ) {
 731+ # No point in saving data to /dev/null
 732+ wfProfileOut( __METHOD__ );
 733+ return;
 734+ }
 735+
714736 # Save to the persistent cache
715737 $this->store->startWrite( $code );
716738 foreach ( $allData as $key => $value ) {
@@ -724,11 +746,7 @@
725747 $this->store->finishWrite();
726748
727749 # Clear out the MessageBlobStore
728 - # HACK: If using a null (i.e. disabled) storage backend, we
729 - # can't write to the MessageBlobStore either
730 - if ( !$this->store instanceof LCStore_Null ) {
731 - MessageBlobStore::clear();
732 - }
 750+ MessageBlobStore::clear();
733751
734752 wfProfileOut( __METHOD__ );
735753 }
@@ -1186,4 +1204,4 @@
11871205 $this->unload( $code );
11881206 }
11891207 }
1190 -}
\ No newline at end of file
 1208+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r102650correct variable name...hashar13:14, 10 November 2011
r102674Revert r102650, r102640. Caused breakage on translatewiki.net:...siebrand19:01, 10 November 2011

Comments

#Comment by Reedy (talk | contribs)   12:03, 10 November 2011
#Comment by Platonides (talk | contribs)   15:34, 10 November 2011

I think the call should have also been $this->saveLangInStore( $code, $allData ); ? $data is a much earlier variable which doesn't seem expected to be used outside its foreach.

#Comment by Siebrand (talk | contribs)   18:47, 10 November 2011
No localisation cache found for English. Please run maintenance/rebuildLocalisationCache.php.

Backtrace:

#0 /www/w/includes/LocalisationCache.php(288): LocalisationCache->initLanguage('en')
#1 /www/w/includes/LocalisationCache.php(223): LocalisationCache->loadItem('en', 'specialPageAlia...')
#2 /www/w/languages/Language.php(2630): LocalisationCache->getItem('en', 'specialPageAlia...')
#3 /www/w/includes/SpecialPageFactory.php(211): Language->getSpecialPageAliases()
#4 /www/w/includes/SpecialPageFactory.php(247): SpecialPageFactory::getAliasList()
#5 /www/w/includes/Title.php(4186): SpecialPageFactory::resolveAlias('LanguageStats/n...')
#6 /www/w/includes/Wiki.php(154): Title->isSpecial('Badtitle')
#7 /www/w/includes/Wiki.php(605): MediaWiki->performRequest()
#8 /www/w/includes/Wiki.php(524): MediaWiki->main()
#9 /www/w/index.php(58): MediaWiki->run()
#10 {main}

Br0ked me site, Sir!

Status & tagging log