Merge "add htmlform-no and htmlform-yes messages for generic yes-no questions"
[lhc/web/wiklou.git] / maintenance / mctest.php
index 42461c5..469feca 100644 (file)
@@ -36,19 +36,26 @@ class mcTest extends Maintenance {
                $this->mDescription = "Makes several 'set', 'incr' and 'get' requests on every"
                                                          . " memcached server and shows a report";
                $this->addOption( 'i', 'Number of iterations', false, true );
+               $this->addOption( 'cache', 'Use servers from this $wgObjectCaches store', false, true );
                $this->addArg( 'server[:port]', 'Memcached server to test, with optional port', false );
        }
 
        public function execute() {
                global $wgMainCacheType, $wgMemCachedTimeout, $wgObjectCaches;
 
+               $cache = $this->getOption( 'cache' );
                $iterations = $this->getOption( 'i', 100 );
-               if ( $this->hasArg() ) {
+               if ( $cache ) {
+                       if ( !isset( $wgObjectCaches[$cache] ) ) {
+                               $this->error( "MediaWiki isn't configured with a cache named '$cache'", 1 );
+                       }
+                       $servers = $wgObjectCaches[$cache]['servers'];
+               } elseif ( $this->hasArg() ) {
                        $servers = array( $this->getArg() );
                } elseif ( $wgMainCacheType === CACHE_MEMCACHED ) {
                        global $wgMemCachedServers;
                        $servers = $wgMemCachedServers ;
-               } elseif( isset( $wgObjectCaches[$wgMainCacheType] ) ) {
+               } elseif ( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) {
                        $servers = $wgObjectCaches[$wgMainCacheType]['servers'];
                } else {
                        $this->error( "MediaWiki isn't configured for Memcached usage", 1 );