If a maintenance script is called with --help (or without
required args), this is currently failing, as MediaWikiServices
is only loaded after Maintenance::setup is initially called.
Follows
336454104d1249439e3ff97746de69c5e7b4a5f9.
Change-Id: Ied283d362675b6b98bd3144132a240b432998991
* @param mixed $channel Unique identifier for the channel. See function outputChanneled.
*/
protected function output( $out, $channel = null ) {
* @param mixed $channel Unique identifier for the channel. See function outputChanneled.
*/
protected function output( $out, $channel = null ) {
- // Try to periodically flush buffered metrics to avoid OOMs
- $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
- if ( $stats->getDataCount() > 1000 ) {
- MediaWiki::emitBufferedStatsdData( $stats, $this->getConfig() );
+ // This is sometimes called very early, before Setup.php is included.
+ if ( class_exists( MediaWikiServices::class ) ) {
+ // Try to periodically flush buffered metrics to avoid OOMs
+ $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
+ if ( $stats->getDataCount() > 1000 ) {
+ MediaWiki::emitBufferedStatsdData( $stats, $this->getConfig() );
+ }
if ( $this->mQuiet ) {
return;
}
if ( $this->mQuiet ) {
return;
}