Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -827,27 +827,62 @@ |
828 | 828 | |
829 | 829 | return $checker; |
830 | 830 | } |
| 831 | + |
| 832 | + public function getDescription() { |
| 833 | + $title = $this->title; |
| 834 | + $target = SpecialPage::getTitleFor( 'MyLanguage', $title )->getPrefixedText(); |
| 835 | + return wfMsgNoTrans( 'translate-tag-page-desc', $title, $target ); |
| 836 | + } |
831 | 837 | } |
832 | 838 | |
833 | 839 | class MessageGroups { |
834 | 840 | public static function init() { |
835 | 841 | static $loaded = false; |
| 842 | + if ( $loaded ) return; |
| 843 | + $loaded = true; |
836 | 844 | |
837 | | - if ( $loaded ) { |
838 | | - return; |
| 845 | + global $wgTranslateCC, $wgTranslateEC, $wgTranslateAC; |
| 846 | + global $wgAutoloadClasses; |
| 847 | + |
| 848 | + $key = wfMemckey( 'translate-groups' ); |
| 849 | + $cache = wfGetCache( CACHE_DB ); |
| 850 | + $value = DependencyWrapper::getValueFromCache( $cache, $key ); |
| 851 | + |
| 852 | + if ( $value === null ) { |
| 853 | + wfDebug( __METHOD__ . "-nocache\n" ); |
| 854 | + self::loadGroupDefinitions(); |
| 855 | + } else { |
| 856 | + wfDebug( __METHOD__ . "-withcache\n" ); |
| 857 | + $wgTranslateCC = $value['cc']; |
| 858 | + $wgTranslateAC = $value['ac']; |
| 859 | + $wgTranslateEC = $value['ec']; |
| 860 | + |
| 861 | + foreach ( $value['autoload'] as $class => $file ) { |
| 862 | + $wgAutoloadClasses[$class] = $file; |
| 863 | + } |
839 | 864 | } |
840 | | - wfDebug( __METHOD__ . "\n" ); |
| 865 | + } |
841 | 866 | |
| 867 | + public static function loadGroupDefinitions() { |
842 | 868 | global $wgTranslateAddMWExtensionGroups; |
| 869 | + global $wgEnablePageTranslation, $wgTranslateGroupFiles; |
| 870 | + global $wgTranslateAC, $wgTranslateEC, $wgTranslateCC; |
| 871 | + global $wgAutoloadClasses; |
843 | 872 | |
| 873 | + $deps = array(); |
| 874 | + $deps[] = new GlobalDependency( 'wgTranslateAddMWExtensionGroups' ); |
| 875 | + $deps[] = new GlobalDependency( 'wgEnablePageTranslation' ); |
| 876 | + $deps[] = new GlobalDependency( 'wgTranslateGroupFiles' ); |
| 877 | + $deps[] = new GlobalDependency( 'wgTranslateAC' ); |
| 878 | + $deps[] = new GlobalDependency( 'wgTranslateEC' ); |
| 879 | + $deps[] = new GlobalDependency( 'wgTranslateCC' ); |
| 880 | + $deps[] = New FileDependency( dirname( __FILE__ ) . '/groups/mediawiki-defines.txt' ); |
| 881 | + |
844 | 882 | if ( $wgTranslateAddMWExtensionGroups ) { |
845 | 883 | $a = new PremadeMediawikiExtensionGroups; |
846 | 884 | $a->addAll(); |
847 | 885 | } |
848 | 886 | |
849 | | - global $wgTranslateCC; |
850 | | - global $wgEnablePageTranslation; |
851 | | - |
852 | 887 | if ( $wgEnablePageTranslation ) { |
853 | 888 | $dbr = wfGetDB( DB_SLAVE ); |
854 | 889 | |
— | — | @@ -862,24 +897,25 @@ |
863 | 898 | $id = "page|$title"; |
864 | 899 | $wgTranslateCC[$id] = new WikiPageMessageGroup( $id, $title ); |
865 | 900 | $wgTranslateCC[$id]->setLabel( $title ); |
866 | | - $target = SpecialPage::getTitleFor( 'MyLanguage', $title )->getPrefixedText(); |
867 | | - $wgTranslateCC[$id]->setDescription( wfMsgNoTrans( 'translate-tag-page-desc', $title, $target ) ); |
868 | 901 | } |
869 | 902 | } |
870 | 903 | |
871 | 904 | wfRunHooks( 'TranslatePostInitGroups', array( &$wgTranslateCC ) ); |
872 | 905 | |
873 | | - global $wgTranslateGroupFiles, $wgAutoloadClasses; |
| 906 | + $autoload = array(); |
874 | 907 | |
875 | 908 | foreach ( $wgTranslateGroupFiles as $configFile ) { |
876 | 909 | wfDebug( $configFile . "\n" ); |
| 910 | + $deps[] = new FileDependency( realpath( $configFile ) ); |
877 | 911 | $fgroups = TranslateYaml::parseGroupFile( $configFile ); |
878 | 912 | |
879 | 913 | foreach( $fgroups as $id => $conf ) { |
880 | 914 | if ( !empty( $conf['AUTOLOAD'] ) && is_array( $conf['AUTOLOAD'] ) ) { |
881 | 915 | $dir = dirname( $configFile ); |
882 | 916 | foreach ( $conf['AUTOLOAD'] as $class => $file ) { |
| 917 | + // For this request and for caching |
883 | 918 | $wgAutoloadClasses[$class] = "$dir/$file"; |
| 919 | + $autoload[$class] = "$dir/$file"; |
884 | 920 | } |
885 | 921 | } |
886 | 922 | $group = MessageGroupBase::factory( $conf ); |
— | — | @@ -887,7 +923,19 @@ |
888 | 924 | } |
889 | 925 | } |
890 | 926 | |
891 | | - $loaded = true; |
| 927 | + $key = wfMemckey( 'translate-groups' ); |
| 928 | + $cache = wfGetCache( CACHE_DB ); |
| 929 | + $value = array( |
| 930 | + 'ac' => $wgTranslateAC, |
| 931 | + 'ec' => $wgTranslateEC, |
| 932 | + 'cc' => $wgTranslateCC, |
| 933 | + 'autoload' => $autoload, |
| 934 | + ); |
| 935 | + |
| 936 | + $wrapper = new DependencyWrapper( $value, $deps ); |
| 937 | + $wrapper->storeToCache( $cache, $key, 60*60*2 ); |
| 938 | + |
| 939 | + wfDebug( __METHOD__ . "-end\n" ); |
892 | 940 | } |
893 | 941 | |
894 | 942 | public static function getGroup( $id ) { |