rdbms: reduce LoadBalancer replication log spam
[lhc/web/wiklou.git] / maintenance / mcc.php
index 4e0f291..784ba0e 100644 (file)
  * @ingroup Maintenance
  */
 
-/** */
-require_once( __DIR__ . '/commandLine.inc' );
+$optionsWithArgs = [ 'cache' ];
+$optionsWithoutArgs = [
+       'debug', 'help'
+];
+require_once __DIR__ . '/commandLine.inc';
 
-$debug = in_array( '--debug', $argv );
-$help = in_array( '--help', $argv );
+$debug = isset( $options['debug'] );
+$help = isset( $options['help'] );
+$cache = isset( $options['cache'] ) ? $options['cache'] : null;
 
-if( $help ) {
+if ( $help ) {
        mccShowUsage();
        exit( 0 );
 }
-$mcc = new MWMemcached( array(
+$mcc = new MemcachedClient( [
        'persistent' => true,
        'debug' => $debug,
-) );
+] );
 
-if ( $wgMainCacheType === CACHE_MEMCACHED ) {
+if ( $cache ) {
+       if ( !isset( $wgObjectCaches[$cache] ) ) {
+               print "MediaWiki isn't configured with a cache named '$cache'";
+               exit( 1 );
+       }
+       $servers = $wgObjectCaches[$cache]['servers'];
+} elseif ( $wgMainCacheType === CACHE_MEMCACHED ) {
        $mcc->set_servers( $wgMemCachedServers );
-} elseif( isset( $wgObjectCaches[$wgMainCacheType] ) ) {
+} elseif ( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) {
        $mcc->set_servers( $wgObjectCaches[$wgMainCacheType]['servers'] );
 } else {
        print "MediaWiki isn't configured for Memcached usage\n";
@@ -72,7 +82,7 @@ EOF;
 
 function mccGetHelp( $command ) {
        $output = '';
-       $commandList = array(
+       $commandList = [
                'get' => 'grabs something',
                'getsock' => 'lists sockets',
                'set' => 'changes something',
@@ -83,7 +93,7 @@ function mccGetHelp( $command ) {
                'exit' => 'exit mcc',
                'quit' => 'exit mcc',
                'help' => 'help about a command',
-       );
+       ];
        if ( !$command ) {
                $command = 'fullhelp';
        }
@@ -107,7 +117,9 @@ do {
        $quit = false;
 
        $line = Maintenance::readconsole();
-       if ( $line === false ) exit;
+       if ( $line === false ) {
+               exit;
+       }
 
        $args = explode( ' ', $line );
        $command = array_shift( $args );