* @ingroup FileBackend
* @author Aaron Schulz
*/
+use \MediaWiki\Logger\LoggerFactory;
/**
* Class to handle file backend registration
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 += [
+ 'wikiId' => wfWikiID(), // e.g. "my_wiki-en_"
+ 'mimeCallback' => [ $this, 'guessMimeInternal' ],
+ 'obResetFunc' => 'wfResetOutputBuffers',
+ 'streamMimeFunc' => [ 'StreamFile', 'contentTypeFromPath' ]
+ ];
$config['lockManager'] =
LockManagerGroup::singleton( $config['wikiId'] )->get( $config['lockManager'] );
$config['fileJournal'] = isset( $config['fileJournal'] )
? FileJournal::factory( $config['fileJournal'], $name )
: FileJournal::factory( [ 'class' => 'NullFileJournal' ], $name );
$config['wanCache'] = ObjectCache::getMainWANInstance();
- $config['mimeCallback'] = [ $this, 'guessMimeInternal' ];
$config['statusWrapper'] = [ 'Status', 'wrap' ];
$config['tmpDirectory'] = wfTempDir();
+ $config['logger'] = LoggerFactory::getInstance( 'FileOperation' );
+ $config['profiler'] = Profiler::instance();
+ if ( $class === 'FileBackendMultiWrite' ) {
+ foreach ( $config['backends'] as $index => $beConfig ) {
+ if ( isset( $beConfig['template'] ) ) {
+ // Config is just a modified version of a registered backend's.
+ // This should only be used when that config is used only by this backend.
+ $config['backends'][$index] += $this->config( $beConfig['template'] );
+ }
+ }
+ }
$this->backends[$name]['instance'] = new $class( $config );
}