die( 1 );
}
+/** @endcond */
+
/**
* wgConf hold the site configuration.
* Not used for much in a default install.
$wgTitle = $title;
$trxProfiler = Profiler::instance()->getTransactionProfiler();
+ $trxProfiler->setLogger( MWLoggerFactory::getInstance( 'DBPerformance' ) );
// Aside from rollback, master queries should not happen on GET requests.
// Periodic or "in passing" updates on GET should use the job queue.
* Get the singleton instance
*
* @since 1.24
+ * @deprecated since 1.25
* @return MessageBlobStore
*/
public static function getInstance() {
- static $instance = null;
- if ( $instance === null ) {
- $instance = new self;
- }
-
- return $instance;
+ wfDeprecated( __METHOD__, '1.25' );
+ return new self;
}
/**
# HACK: If using a null (i.e. disabled) storage backend, we
# can't write to the MessageBlobStore either
if ( $purgeBlobs && !$this->store instanceof LCStoreNull ) {
- MessageBlobStore::getInstance()->clear();
+ $blobStore = new MessageBlobStore();
+ $blobStore->clear();
}
}
// Update the message in the message blob store
global $wgContLang;
- MessageBlobStore::getInstance()->updateMessage( $wgContLang->lcfirst( $msg ) );
+ $blobStore = new MessageBlobStore();
+ $blobStore->updateMessage( $wgContLang->lcfirst( $msg ) );
Hooks::run( 'MessageCacheReplace', array( $title, $text ) );
if ( $wgLocalisationCacheConf['manualRecache'] ) {
$this->rebuildLocalisationCache();
}
- MessageBlobStore::getInstance()->clear();
+ $blobStore = new MessageBlobStore();
+ $blobStore->clear();
$this->output( "done.\n" );
}
/**
* Implements the default log formatting.
- * Can be overridden by subclassing and setting
- * $wgLogActionsHandlers['type/subtype'] = 'class'; or
- * $wgLogActionsHandlers['type/*'] = 'class';
+ *
+ * Can be overridden by subclassing and setting:
+ *
+ * $wgLogActionsHandlers['type/subtype'] = 'class'; or
+ * $wgLogActionsHandlers['type/*'] = 'class';
+ *
* @since 1.19
*/
class LogFormatter {
* @author Aaron Schulz
*/
+use Psr\Log\LoggerInterface;
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\NullLogger;
/**
* Helper class that detects high-contention DB queries via profiling calls
*
*
* @since 1.24
*/
-class TransactionProfiler {
+class TransactionProfiler implements LoggerAwareInterface {
/** @var float Seconds */
protected $dbLockThreshold = 3.0;
/** @var float Seconds */
/** @var array */
protected $expectBy = array();
+ /**
+ * @var LoggerInterface
+ */
+ private $logger;
+
+ public function __construct() {
+ $this->setLogger( new NullLogger() );
+ }
+
+ public function setLogger( LoggerInterface $logger ) {
+ $this->logger = $logger;
+ }
+
/**
* Set performance expectations
*
public function transactionWritingIn( $server, $db, $id ) {
$name = "{$server} ({$db}) (TRX#$id)";
if ( isset( $this->dbTrxHoldingLocks[$name] ) ) {
- wfDebugLog( 'DBPerformance', "Nested transaction for '$name' - out of sync." );
+ $this->logger->info( "Nested transaction for '$name' - out of sync." );
}
$this->dbTrxHoldingLocks[$name] = array(
'start' => microtime( true ),
$elapsed = ( $eTime - $sTime );
if ( $isWrite && $n > $this->expect['maxAffected'] ) {
- wfDebugLog( 'DBPerformance',
- "Query affected $n row(s):\n" . $query . "\n" . wfBacktrace( true ) );
+ $this->logger->info( "Query affected $n row(s):\n" . $query . "\n" . wfBacktrace( true ) );
}
// Report when too many writes/queries happen...
public function transactionWritingOut( $server, $db, $id ) {
$name = "{$server} ({$db}) (TRX#$id)";
if ( !isset( $this->dbTrxMethodTimes[$name] ) ) {
- wfDebugLog( 'DBPerformance', "Detected no transaction for '$name' - out of sync." );
+ $this->logger->info( "Detected no transaction for '$name' - out of sync." );
return;
}
// Fill in the last non-query period...
list( $query, $sTime, $end ) = $info;
$msg .= sprintf( "%d\t%.6f\t%s\n", $i, ( $end - $sTime ), $query );
}
- wfDebugLog( 'DBPerformance', $msg );
+ $this->logger->info( $msg );
}
unset( $this->dbTrxHoldingLocks[$name] );
unset( $this->dbTrxMethodTimes[$name] );
protected function reportExpectationViolated( $expect, $query ) {
$n = $this->expect[$expect];
$by = $this->expectBy[$expect];
- wfDebugLog( 'DBPerformance',
- "Expectation ($expect <= $n) by $by not met:\n$query\n" . wfBacktrace( true ) );
+ $this->logger->info(
+ "Expectation ($expect <= $n) by $by not met:\n$query\n" . wfBacktrace( true )
+ );
}
}
*/
protected $errors = array();
+ /**
+ * @var MessageBlobStore
+ */
+ protected $blobStore;
+
/**
* Load information stored in the database about modules.
*
$this->registerTestModules();
}
+ $this->setMessageBlobStore( new MessageBlobStore() );
}
/**
return $this->config;
}
+ /**
+ * @param MessageBlobStore $blobStore
+ * @since 1.25
+ */
+ public function setMessageBlobStore( MessageBlobStore $blobStore ) {
+ $this->blobStore = $blobStore;
+ }
+
/**
* Register a module with the ResourceLoader system.
*
// Pre-fetch blobs
if ( $context->shouldIncludeMessages() ) {
try {
- $blobs = MessageBlobStore::getInstance()->get( $this, $modules, $context->getLanguage() );
+ $blobs = $this->blobStore->get( $this, $modules, $context->getLanguage() );
} catch ( Exception $e ) {
MWExceptionHandler::logException( $e );
wfDebugLog(
"public=\access public" \
"copyright=\note" \
"license=\note" \
- "codeCoverageIgnore="
+ "codeCoverageIgnore=" \
+ "codingStandardsIgnoreStart=" \
+ "group=" \
+ "covers=" \
+ "dataProvider=" \
+ "expectedException=" \
+ "expectedExceptionMessage="
TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
$this->template = $IP . '/maintenance/Doxyfile';
$this->excludes = array(
'vendor',
+ 'node_modules',
'images',
'static',
);
$ctx->setLanguage( 'en' );
$out = new OutputPage( $ctx );
$rl = $out->getResourceLoader();
+ $rl->setMessageBlobStore( new NullMessageBlobStore() );
$rl->register( array(
'test.foo' => new ResourceLoaderTestModule( array(
'script' => 'mw.test.foo( { a: true } );',
$this->assertEquals( $expectedHtml, $actualHtml );
}
}
+
+/**
+ * MessageBlobStore that doesn't do anything
+ */
+class NullMessageBlobStore extends MessageBlobStore {
+ public function get ( ResourceLoader $resourceLoader, $modules, $lang ) {
+ return array();
+ }
+
+ public function insertMessageBlob ( $name, ResourceLoaderModule $module, $lang ) {
+ return false;
+ }
+
+ public function updateModule ( $name, ResourceLoaderModule $module, $lang ) {
+ return;
+ }
+
+ public function updateMessage ( $key ) {
+ }
+ public function clear() {
+ }
+}
+