From: Chad Horohoe Date: Mon, 28 Jul 2008 16:02:45 +0000 (+0000) Subject: Fail a little more gracefully if memcached returns nothing (get a bunch of fun divide... X-Git-Tag: 1.31.0-rc.0~46327 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=eb435bcb366d60d16dff391bdb08316b84c33da5;p=lhc%2Fweb%2Fwiklou.git Fail a little more gracefully if memcached returns nothing (get a bunch of fun divide by zero errors otherwise :) --- diff --git a/maintenance/stats.php b/maintenance/stats.php index 9c16e12d3b..a1a8ffe82c 100644 --- a/maintenance/stats.php +++ b/maintenance/stats.php @@ -11,11 +11,13 @@ require_once('commandLine.inc'); if( get_class( $wgMemc ) == 'FakeMemCachedClient' ) { die("You are running FakeMemCachedClient, I can not provide any statistics.\n"); } - -print "Requests\n"; $session = intval($wgMemc->get(wfMemcKey('stats','request_with_session'))); $noSession = intval($wgMemc->get(wfMemcKey('stats','request_without_session'))); $total = $session + $noSession; +if ( $total == 0 ) { + die("You either have no stats or memcached isn't running. Aborting."); +} +print "Requests\n"; printf( "with session: %-10d %6.2f%%\n", $session, $session/$total*100 ); printf( "without session: %-10d %6.2f%%\n", $noSession, $noSession/$total*100 ); printf( "total: %-10d %6.2f%%\n", $total, 100 );