Make "eval.php -d 2" work again
Instead of iterating through load balancer info, just set the flag in the master and replica connections, since that seems more robust. Deprecate LoadBalancer::setServerInfo() and LoadBalancer::getServerInfo(), no remaining callers in core or in-tree extensions, I think I added the function just for this feature. Do a service reset, since Logger instances are injected into LoadBalancer by ServiceWiring (via MWLBFactory::applyDefaultConfig()). Similarly CryptRand, MimeAnalyzer. Fix the usage text for shell.php Change-Id: I3e85a6e8cfa1243a0371cfb3ce1c18665e8c711d
This commit is contained in:
parent
6c93618299
commit
dd8a939ea6
5 changed files with 24 additions and 15 deletions
|
|
@ -43,6 +43,8 @@ changes to languages because of Phabricator reports.
|
|||
the key instead of the value, is deprecated (e.g. [ '127.0.0.1' => 'value' ]).
|
||||
Please convert these arrays to indexed/sequential ones (e.g. [ '127.0.0.1' ]).
|
||||
* mw.user.bucket (deprecated in 1.23) was removed.
|
||||
* LoadBalancer::getServerInfo() and LoadBalancer::setServerInfo() are
|
||||
deprecated. There are no known callers.
|
||||
|
||||
== Compatibility ==
|
||||
MediaWiki 1.30 requires PHP 5.5.9 or later. There is experimental support for
|
||||
|
|
|
|||
|
|
@ -286,6 +286,8 @@ interface ILoadBalancer {
|
|||
* Return the server info structure for a given index, or false if the index is invalid.
|
||||
* @param int $i
|
||||
* @return array|bool
|
||||
*
|
||||
* @deprecated Since 1.30, no alternative
|
||||
*/
|
||||
public function getServerInfo( $i );
|
||||
|
||||
|
|
@ -294,6 +296,8 @@ interface ILoadBalancer {
|
|||
* is created if it doesn't exist
|
||||
* @param int $i
|
||||
* @param array $serverInfo
|
||||
*
|
||||
* @deprecated Since 1.30, construct new object
|
||||
*/
|
||||
public function setServerInfo( $i, array $serverInfo );
|
||||
|
||||
|
|
|
|||
|
|
@ -1033,7 +1033,11 @@ class LoadBalancer implements ILoadBalancer {
|
|||
return ( $name != '' ) ? $name : 'localhost';
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Since 1.30, no alternative
|
||||
*/
|
||||
public function getServerInfo( $i ) {
|
||||
wfDeprecated( __METHOD__, '1.30' );
|
||||
if ( isset( $this->mServers[$i] ) ) {
|
||||
return $this->mServers[$i];
|
||||
} else {
|
||||
|
|
@ -1041,7 +1045,11 @@ class LoadBalancer implements ILoadBalancer {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Since 1.30, construct new object
|
||||
*/
|
||||
public function setServerInfo( $i, array $serverInfo ) {
|
||||
wfDeprecated( __METHOD__, '1.30' );
|
||||
$this->mServers[$i] = $serverInfo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\Logger\ConsoleSpi;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
$optionsWithArgs = [ 'd' ];
|
||||
|
||||
|
|
@ -41,15 +42,12 @@ if ( isset( $options['d'] ) ) {
|
|||
$d = $options['d'];
|
||||
if ( $d > 0 ) {
|
||||
LoggerFactory::registerProvider( new ConsoleSpi );
|
||||
// Some services hold Logger instances in object properties
|
||||
MediaWikiServices::resetGlobalInstance();
|
||||
}
|
||||
if ( $d > 1 ) {
|
||||
$lb = wfGetLB();
|
||||
$serverCount = $lb->getServerCount();
|
||||
for ( $i = 0; $i < $serverCount; $i++ ) {
|
||||
$server = $lb->getServerInfo( $i );
|
||||
$server['flags'] |= DBO_DEBUG;
|
||||
$lb->setServerInfo( $i, $server );
|
||||
}
|
||||
wfGetDB( DB_MASTER )->setFlag( DBO_DEBUG );
|
||||
wfGetDB( DB_REPLICA )->setFlag( DBO_DEBUG );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\Logger\ConsoleSpi;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
||||
|
|
@ -83,17 +84,13 @@ class MediaWikiShell extends Maintenance {
|
|||
$d = intval( $this->getOption( 'd' ) );
|
||||
if ( $d > 0 ) {
|
||||
LoggerFactory::registerProvider( new ConsoleSpi );
|
||||
// Some services hold Logger instances in object properties
|
||||
MediaWikiServices::resetGlobalInstance();
|
||||
}
|
||||
if ( $d > 1 ) {
|
||||
# Set DBO_DEBUG (equivalent of $wgDebugDumpSql)
|
||||
# XXX copy pasted from eval.php :(
|
||||
$lb = wfGetLB();
|
||||
$serverCount = $lb->getServerCount();
|
||||
for ( $i = 0; $i < $serverCount; $i++ ) {
|
||||
$server = $lb->getServerInfo( $i );
|
||||
$server['flags'] |= DBO_DEBUG;
|
||||
$lb->setServerInfo( $i, $server );
|
||||
}
|
||||
wfGetDB( DB_MASTER )->setFlag( DBO_DEBUG );
|
||||
wfGetDB( DB_REPLICA )->setFlag( DBO_DEBUG );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue