X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fmcc.php;h=784ba0ea357496bee9c3d0118a0331561587e40a;hb=56ade0650d492e01d2689dc918e7db3d56d18147;hp=4e0f291b73ffc4223b86c10b78997c59875b9bb1;hpb=04b47c018040aa8cf520cbbaab4071dac54a6b27;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/mcc.php b/maintenance/mcc.php index 4e0f291b73..784ba0ea35 100644 --- a/maintenance/mcc.php +++ b/maintenance/mcc.php @@ -22,24 +22,34 @@ * @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 );