Merge "rdbms: Restore debug toolbar "Queries" feature"
This commit is contained in:
commit
4b6468ba66
5 changed files with 17 additions and 18 deletions
|
|
@ -6160,9 +6160,8 @@ $wgDebugComments = false;
|
|||
* Write SQL queries to the debug log.
|
||||
*
|
||||
* This setting is only used $wgLBFactoryConf['class'] is set to
|
||||
* '\Wikimedia\Rdbms\LBFactorySimple' and $wgDBservers is an empty array; otherwise
|
||||
* the DBO_DEBUG flag must be set in the 'flags' option of the database
|
||||
* connection to achieve the same functionality.
|
||||
* '\Wikimedia\Rdbms\LBFactorySimple'; otherwise the DBO_DEBUG flag must be set in
|
||||
* the 'flags' option of the database connection to achieve the same functionality.
|
||||
*/
|
||||
$wgDebugDumpSql = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -196,13 +196,14 @@ abstract class MWLBFactory {
|
|||
$server += [ 'schema' => $options->get( 'DBmwschema' ) ];
|
||||
}
|
||||
|
||||
$flags = DBO_DEFAULT;
|
||||
$flags |= $options->get( 'DebugDumpSql' ) ? DBO_DEBUG : 0;
|
||||
$flags |= $options->get( 'DebugLogFile' ) ? DBO_DEBUG : 0;
|
||||
$flags = $server['flags'] ?? DBO_DEFAULT;
|
||||
if ( $options->get( 'DebugDumpSql' ) || $options->get( 'DebugLogFile' ) ) {
|
||||
$flags |= DBO_DEBUG;
|
||||
}
|
||||
$server['flags'] = $flags;
|
||||
|
||||
$server += [
|
||||
'tablePrefix' => $options->get( 'DBprefix' ),
|
||||
'flags' => $flags,
|
||||
'sqlMode' => $options->get( 'SQLMode' ),
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -371,11 +371,11 @@ class MWDebug {
|
|||
* @since 1.19
|
||||
* @param string $sql
|
||||
* @param string $function
|
||||
* @param bool $isMaster
|
||||
* @param float $runTime Query run time
|
||||
* @param string $dbhost
|
||||
* @return bool True if debugger is enabled, false otherwise
|
||||
*/
|
||||
public static function query( $sql, $function, $isMaster, $runTime ) {
|
||||
public static function query( $sql, $function, $runTime, $dbhost ) {
|
||||
if ( !self::$enabled ) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -406,9 +406,8 @@ class MWDebug {
|
|||
$sql = UtfNormal\Validator::cleanUp( $sql );
|
||||
|
||||
self::$query[] = [
|
||||
'sql' => $sql,
|
||||
'sql' => "$dbhost: $sql",
|
||||
'function' => $function,
|
||||
'master' => (bool)$isMaster,
|
||||
'time' => $runTime,
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -102,16 +102,15 @@ class LegacyLogger extends AbstractLogger {
|
|||
$level = self::$levelMapping[$level];
|
||||
}
|
||||
if ( $this->channel === 'DBQuery'
|
||||
&& isset( $context['method'] )
|
||||
&& isset( $context['master'] )
|
||||
&& isset( $context['runtime'] )
|
||||
&& $level === self::$levelMapping[LogLevel::DEBUG]
|
||||
&& isset( $context['sql'] )
|
||||
) {
|
||||
// Also give the query information to the MWDebug tools
|
||||
$enabled = MWDebug::query(
|
||||
$message,
|
||||
$context['sql'],
|
||||
$context['method'],
|
||||
$context['master'],
|
||||
$context['runtime']
|
||||
$context['runtime'],
|
||||
$context['db_host']
|
||||
);
|
||||
if ( $enabled ) {
|
||||
// If we the toolbar was enabled, return early so that we don't
|
||||
|
|
|
|||
|
|
@ -1347,10 +1347,11 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
// Avoid the overhead of logging calls unless debug mode is enabled
|
||||
if ( $this->getFlag( self::DBO_DEBUG ) ) {
|
||||
$this->queryLogger->debug(
|
||||
"{method} [{runtime}s] {db_host}: $sql",
|
||||
"{method} [{runtime}s] {db_host}: {sql}",
|
||||
[
|
||||
'method' => $fname,
|
||||
'db_host' => $this->getServer(),
|
||||
'sql' => $sql,
|
||||
'domain' => $this->getDomainID(),
|
||||
'runtime' => round( $queryRuntime, 3 )
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue