'wanCache' => MediaWikiServices::getInstance()->getMainWANObjectCache(),
'srvCache' => ObjectCache::getLocalServerInstance( 'hash' ),
'logger' => LoggerFactory::getInstance( 'FileOperation' ),
- 'profiler' => Profiler::instance()
+ 'profiler' => function ( $section ) {
+ return Profiler::instance()->scopedProfileIn( $section );
+ }
];
$config['lockManager'] =
LockManagerGroup::singleton( $config['wikiId'] )->get( $config['lockManager'] );
protected $fileJournal;
/** @var LoggerInterface */
protected $logger;
- /** @var object|string Class name or object With profileIn/profileOut methods */
+ /** @var callable|null */
protected $profiler;
/** @var callable */
* - obResetFunc : alternative callback to clear the output buffer
* - streamMimeFunc : alternative method to determine the content type from the path
* - logger : Optional PSR logger object.
- * - profiler : Optional class name or object With profileIn/profileOut methods.
+ * - profiler : Optional callback that takes a section name argument and returns
+ * a ScopedCallback instance that ends the profile section in its destructor.
* @throws InvalidArgumentException
*/
public function __construct( array $config ) {
$this->statusWrapper = $config['statusWrapper'] ?? null;
$this->profiler = $config['profiler'] ?? null;
+ if ( !is_callable( $this->profiler ) ) {
+ $this->profiler = null;
+ }
$this->logger = $config['logger'] ?? new \Psr\Log\NullLogger();
$this->statusWrapper = $config['statusWrapper'] ?? null;
$this->tmpDirectory = $config['tmpDirectory'] ?? null;
* @return ScopedCallback|null
*/
protected function scopedProfileSection( $section ) {
- if ( $this->profiler ) {
- call_user_func( [ $this->profiler, 'profileIn' ], $section );
- return new ScopedCallback( [ $this->profiler, 'profileOut' ], [ $section ] );
- }
-
- return null;
+ return $this->profiler ? ( $this->profiler )( $section ) : null;
}
protected function resetOutputBuffer() {