Merge "Remove unused 'XMPGetInfo' and 'XMPGetResults' hooks"
[lhc/web/wiklou.git] / includes / filebackend / FileBackendGroup.php
index 491424b..9bb1582 100644 (file)
@@ -113,18 +113,18 @@ class FileBackendGroup {
         * Register an array of file backend configurations
         *
         * @param array $configs
-        * @throws MWException
+        * @throws FileBackendException
         */
        protected function register( array $configs ) {
                foreach ( $configs as $config ) {
                        if ( !isset( $config['name'] ) ) {
-                               throw new MWException( "Cannot register a backend with no name." );
+                               throw new FileBackendException( "Cannot register a backend with no name." );
                        }
                        $name = $config['name'];
                        if ( isset( $this->backends[$name] ) ) {
-                               throw new MWException( "Backend with name `{$name}` already registered." );
+                               throw new FileBackendException( "Backend with name `{$name}` already registered." );
                        } elseif ( !isset( $config['class'] ) ) {
-                               throw new MWException( "Cannot register backend `{$name}` with no class." );
+                               throw new FileBackendException( "Backend with name `{$name}` has no class." );
                        }
                        $class = $config['class'];
 
@@ -142,16 +142,26 @@ class FileBackendGroup {
         *
         * @param string $name
         * @return FileBackend
-        * @throws MWException
+        * @throws FileBackendException
         */
        public function get( $name ) {
                if ( !isset( $this->backends[$name] ) ) {
-                       throw new MWException( "No backend defined with the name `$name`." );
+                       throw new FileBackendException( "No backend defined with the name `$name`." );
                }
                // Lazy-load the actual backend instance
                if ( !isset( $this->backends[$name]['instance'] ) ) {
                        $class = $this->backends[$name]['class'];
                        $config = $this->backends[$name]['config'];
+                       $config['wikiId'] = isset( $config['wikiId'] )
+                               ? $config['wikiId']
+                               : wfWikiID(); // e.g. "my_wiki-en_"
+                       $config['lockManager'] =
+                               LockManagerGroup::singleton( $config['wikiId'] )->get( $config['lockManager'] );
+                       $config['fileJournal'] = isset( $config['fileJournal'] )
+                               ? FileJournal::factory( $config['fileJournal'], $name )
+                               : FileJournal::factory( array( 'class' => 'NullFileJournal' ), $name );
+                       $config['wanCache'] = ObjectCache::getMainWANInstance();
+
                        $this->backends[$name]['instance'] = new $class( $config );
                }
 
@@ -163,11 +173,11 @@ class FileBackendGroup {
         *
         * @param string $name
         * @return array
-        * @throws MWException
+        * @throws FileBackendException
         */
        public function config( $name ) {
                if ( !isset( $this->backends[$name] ) ) {
-                       throw new MWException( "No backend defined with the name `$name`." );
+                       throw new FileBackendException( "No backend defined with the name `$name`." );
                }
                $class = $this->backends[$name]['class'];