* @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";
function mccGetHelp( $command ) {
$output = '';
- $commandList = array(
+ $commandList = [
'get' => 'grabs something',
'getsock' => 'lists sockets',
'set' => 'changes something',
'exit' => 'exit mcc',
'quit' => 'exit mcc',
'help' => 'help about a command',
- );
+ ];
if ( !$command ) {
$command = 'fullhelp';
}
$quit = false;
$line = Maintenance::readconsole();
- if ( $line === false ) exit;
+ if ( $line === false ) {
+ exit;
+ }
$args = explode( ' ', $line );
$command = array_shift( $args );