r67396 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67395‎ | r67396 | r67397 >
Date:11:07, 5 June 2010
Author:liangent
Status:deferred
Tags:
Comment:
Store a serialized version of data for better performance
Modified paths:
  • /trunk/extensions/CategoryMultisortChinese/CategoryMultisortChinese.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryMultisortChinese/CategoryMultisortChinese.hooks.php
@@ -16,12 +16,27 @@
1717 }
1818 }
1919
 20+ function onCategoryMultisortSortkeys_loadData() {
 21+ $file = dirname( __FILE__ ) . '/CategoryMultisortChinese.dat';
 22+
 23+ if ( file_exists( $file ) ) {
 24+ $data = unserialize( file_get_contents( $file ) );
 25+ if ( $data ) {
 26+ return $data;
 27+ }
 28+ }
 29+
 30+ $data = new CategoryMultisortChineseData();
 31+ file_put_contents( $file, serialize( $data ) );
 32+ return $data;
 33+ }
 34+
2035 function onCategoryMultisortSortkeys( $parser, $category, &$categoryMultisorts ) {
2136 global $wgContLang;
2237
2338 static $data = null;
2439 if ( is_null( $data ) ) {
25 - $data = new CategoryMultisortChineseData();
 40+ $data = $this->onCategoryMultisortSortkeys_loadData();
2641 }
2742
2843 $title = $parser->getTitle();

Status & tagging log