Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -845,8 +845,7 @@ |
846 | 846 | global $wgAutoloadClasses; |
847 | 847 | |
848 | 848 | $key = wfMemckey( 'translate-groups' ); |
849 | | - $cache = wfGetCache( CACHE_DB ); |
850 | | - $value = DependencyWrapper::getValueFromCache( $cache, $key ); |
| 849 | + $value = DependencyWrapper::getValueFromCache( self::getCache(), $key ); |
851 | 850 | |
852 | 851 | if ( $value === null ) { |
853 | 852 | wfDebug( __METHOD__ . "-nocache\n" ); |
— | — | @@ -863,6 +862,24 @@ |
864 | 863 | } |
865 | 864 | } |
866 | 865 | |
| 866 | + /** |
| 867 | + * Manually reset groups when dependencies cannot |
| 868 | + * detect those automatically |
| 869 | + */ |
| 870 | + public static function clearCache() { |
| 871 | + $key = wfMemckey( 'translate-groups' ); |
| 872 | + self::getCache()->delete( $key ); |
| 873 | + } |
| 874 | + |
| 875 | + /** |
| 876 | + * Returns a cache object. Currently just wrapper for |
| 877 | + * database cache, but could be improved or replaced |
| 878 | + * with something that prefers Memcached over db. |
| 879 | + */ |
| 880 | + protected static function getCache() { |
| 881 | + return wfGetCache( CACHE_DB ); |
| 882 | + } |
| 883 | + |
867 | 884 | public static function loadGroupDefinitions() { |
868 | 885 | global $wgTranslateAddMWExtensionGroups; |
869 | 886 | global $wgEnablePageTranslation, $wgTranslateGroupFiles; |
— | — | @@ -924,7 +941,6 @@ |
925 | 942 | } |
926 | 943 | |
927 | 944 | $key = wfMemckey( 'translate-groups' ); |
928 | | - $cache = wfGetCache( CACHE_DB ); |
929 | 945 | $value = array( |
930 | 946 | 'ac' => $wgTranslateAC, |
931 | 947 | 'ec' => $wgTranslateEC, |
— | — | @@ -933,7 +949,7 @@ |
934 | 950 | ); |
935 | 951 | |
936 | 952 | $wrapper = new DependencyWrapper( $value, $deps ); |
937 | | - $wrapper->storeToCache( $cache, $key, 60*60*2 ); |
| 953 | + $wrapper->storeToCache( self::getCache(), $key, 60*60*2 ); |
938 | 954 | |
939 | 955 | wfDebug( __METHOD__ . "-end\n" ); |
940 | 956 | } |
— | — | @@ -972,32 +988,34 @@ |
973 | 989 | } |
974 | 990 | } |
975 | 991 | |
976 | | - public $classes = array(); |
| 992 | + public $classes; |
977 | 993 | private function __construct() { |
978 | 994 | self::init(); |
979 | 995 | |
980 | | - global $wgTranslateEC, $wgTranslateCC; |
981 | 996 | |
982 | | - $all = array_merge( $wgTranslateEC, array_keys( $wgTranslateCC ) ); |
983 | | - sort( $all ); |
984 | | - |
985 | | - foreach ( $all as $id ) { |
986 | | - $g = self::getGroup( $id ); |
987 | | - $this->classes[$g->getId()] = $g; |
988 | | - } |
989 | 997 | } |
990 | 998 | |
991 | 999 | public static function singleton() { |
992 | 1000 | static $instance; |
993 | | - |
994 | 1001 | if ( !$instance instanceof self ) { |
995 | 1002 | $instance = new self(); |
996 | 1003 | } |
997 | | - |
998 | 1004 | return $instance; |
999 | 1005 | } |
1000 | 1006 | |
1001 | 1007 | public function getGroups() { |
| 1008 | + if ( $this->classes === null ) { |
| 1009 | + $this->classes = array(); |
| 1010 | + global $wgTranslateEC, $wgTranslateCC; |
| 1011 | + |
| 1012 | + $all = array_merge( $wgTranslateEC, array_keys( $wgTranslateCC ) ); |
| 1013 | + sort( $all ); |
| 1014 | + |
| 1015 | + foreach ( $all as $id ) { |
| 1016 | + $g = self::getGroup( $id ); |
| 1017 | + $this->classes[$g->getId()] = $g; |
| 1018 | + } |
| 1019 | + } |
1002 | 1020 | return $this->classes; |
1003 | 1021 | } |
1004 | 1022 | } |
Index: trunk/extensions/Translate/tag/TranslatablePage.php |
— | — | @@ -330,6 +330,7 @@ |
331 | 331 | |
332 | 332 | public function addMarkedTag( $revision, $value = null ) { |
333 | 333 | $this->addTag( 'tp:mark', $revision, $value ); |
| 334 | + MessageGroups::clearCache(); |
334 | 335 | } |
335 | 336 | |
336 | 337 | public function addReadyTag( $revision ) { |
Index: trunk/extensions/Translate/tag/SpecialPageTranslationMovePage.php |
— | — | @@ -341,6 +341,7 @@ |
342 | 342 | $newTpage->addMarkedTag( $this->newTitle->getLatestRevId( GAID_FOR_UPDATE ) ); |
343 | 343 | } |
344 | 344 | |
| 345 | + MessageGroups::clearCache(); |
345 | 346 | //TODO: defer or make faster |
346 | 347 | MessageIndexRebuilder::execute(); |
347 | 348 | |