Index: trunk/phase3/includes/LocalisationCache.php |
— | — | @@ -143,6 +143,7 @@ |
144 | 144 | global $wgCacheDirectory; |
145 | 145 | |
146 | 146 | $this->conf = $conf; |
| 147 | + $storeConf = array(); |
147 | 148 | if ( !empty( $conf['storeClass'] ) ) { |
148 | 149 | $storeClass = $conf['storeClass']; |
149 | 150 | } else { |
— | — | @@ -164,7 +165,11 @@ |
165 | 166 | } |
166 | 167 | |
167 | 168 | wfDebug( get_class( $this ) . ": using store $storeClass\n" ); |
168 | | - $this->store = new $storeClass; |
| 169 | + if ( !empty( $conf['storeDirectory'] ) ) { |
| 170 | + $storeConf['directory'] = $conf['storeDirectory']; |
| 171 | + } |
| 172 | + |
| 173 | + $this->store = new $storeClass( $storeConf ); |
169 | 174 | foreach ( array( 'manualRecache', 'forceRecache' ) as $var ) { |
170 | 175 | if ( isset( $conf[$var] ) ) { |
171 | 176 | $this->$var = $conf[$var]; |
— | — | @@ -775,8 +780,17 @@ |
776 | 781 | * See Cdb.php and http://cr.yp.to/cdb.html |
777 | 782 | */ |
778 | 783 | class LCStore_CDB implements LCStore { |
779 | | - var $readers, $writer, $currentLang; |
780 | | - |
| 784 | + var $readers, $writer, $currentLang, $directory; |
| 785 | + |
| 786 | + function __construct( $conf = array() ) { |
| 787 | + global $wgCacheDirectory; |
| 788 | + if ( isset( $conf['directory'] ) ) { |
| 789 | + $this->directory = $conf['directory']; |
| 790 | + } else { |
| 791 | + $this->directory = $wgCacheDirectory; |
| 792 | + } |
| 793 | + } |
| 794 | + |
781 | 795 | public function get( $code, $key ) { |
782 | 796 | if ( !isset( $this->readers[$code] ) ) { |
783 | 797 | $fileName = $this->getFileName( $code ); |
— | — | @@ -798,6 +812,12 @@ |
799 | 813 | } |
800 | 814 | |
801 | 815 | public function startWrite( $code ) { |
| 816 | + if ( !file_exists( $this->directory ) ) { |
| 817 | + if ( !wfMkdirParents( $this->directory ) ) { |
| 818 | + throw new MWException( "Unable to create the localisation store " . |
| 819 | + "directory \"{$this->directory}\"" ); |
| 820 | + } |
| 821 | + } |
802 | 822 | $this->writer = CdbWriter::open( $this->getFileName( $code ) ); |
803 | 823 | $this->currentLang = $code; |
804 | 824 | } |
— | — | @@ -823,11 +843,10 @@ |
824 | 844 | } |
825 | 845 | |
826 | 846 | protected function getFileName( $code ) { |
827 | | - global $wgCacheDirectory; |
828 | 847 | if ( !$code || strpos( $code, '/' ) !== false ) { |
829 | 848 | throw new MWException( __METHOD__.": Invalid language \"$code\"" ); |
830 | 849 | } |
831 | | - return "$wgCacheDirectory/l10n_cache-$code.cdb"; |
| 850 | + return "{$this->directory}/l10n_cache-$code.cdb"; |
832 | 851 | } |
833 | 852 | } |
834 | 853 | |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -166,7 +166,11 @@ |
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Directory for caching data in the local filesystem. Should not be accessible |
170 | | - * from the web.Set this to false to not use any local caches. |
| 170 | + * from the web. Set this to false to not use any local caches. |
| 171 | + * |
| 172 | + * Note: if multiple wikis share the same localisation cache directory, they |
| 173 | + * must all have the same set of extensions. You can set a directory just for |
| 174 | + * the localisation cache using $wgLocalisationCacheConf['storeDirectory']. |
171 | 175 | */ |
172 | 176 | $wgCacheDirectory = false; |
173 | 177 | |
— | — | @@ -778,22 +782,26 @@ |
779 | 783 | * class: The class to use. May be overridden by extensions. |
780 | 784 | * |
781 | 785 | * store: The location to store cache data. May be 'files', 'db' or |
782 | | - * 'detect'. If set to "files", data will be in CDB files in |
783 | | - * the directory specified by $wgCacheDirectory. If set to "db", |
784 | | - * data will be stored to the database. If set to "detect", files |
785 | | - * will be used if $wgCacheDirectory is set, otherwise the |
786 | | - * database will be used. |
| 786 | + * 'detect'. If set to "files", data will be in CDB files. If set |
| 787 | + * to "db", data will be stored to the database. If set to |
| 788 | + * "detect", files will be used if $wgCacheDirectory is set, |
| 789 | + * otherwise the database will be used. |
787 | 790 | * |
788 | 791 | * storeClass: The class name for the underlying storage. If set to a class |
789 | 792 | * name, it overrides the "store" setting. |
790 | 793 | * |
791 | | - * manualRecache: Set this to true to disable cache updates on web requests. |
792 | | - * Use maintenance/rebuildLocalisationCache.php instead. |
| 794 | + * storeDirectory: If the store class puts its data in files, this is the |
| 795 | + * directory it will use. If this is false, $wgCacheDirectory |
| 796 | + * will be used. |
| 797 | + * |
| 798 | + * manualRecache: Set this to true to disable cache updates on web requests. |
| 799 | + * Use maintenance/rebuildLocalisationCache.php instead. |
793 | 800 | */ |
794 | 801 | $wgLocalisationCacheConf = array( |
795 | 802 | 'class' => 'LocalisationCache', |
796 | 803 | 'store' => 'detect', |
797 | 804 | 'storeClass' => false, |
| 805 | + 'storeDirectory' => false, |
798 | 806 | 'manualRecache' => false, |
799 | 807 | ); |
800 | 808 | |