r38138 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38137‎ | r38138 | r38139 >
Date:16:02, 28 July 2008
Author:demon
Status:old
Tags:
Comment:
Fail a little more gracefully if memcached returns nothing (get a bunch of fun divide by zero errors otherwise :)
Modified paths:
  • /trunk/phase3/maintenance/stats.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/stats.php
@@ -11,11 +11,13 @@
1212 if( get_class( $wgMemc ) == 'FakeMemCachedClient' ) {
1313 die("You are running FakeMemCachedClient, I can not provide any statistics.\n");
1414 }
15 -
16 -print "Requests\n";
1715 $session = intval($wgMemc->get(wfMemcKey('stats','request_with_session')));
1816 $noSession = intval($wgMemc->get(wfMemcKey('stats','request_without_session')));
1917 $total = $session + $noSession;
 18+if ( $total == 0 ) {
 19+ die("You either have no stats or memcached isn't running. Aborting.");
 20+}
 21+print "Requests\n";
2022 printf( "with session: %-10d %6.2f%%\n", $session, $session/$total*100 );
2123 printf( "without session: %-10d %6.2f%%\n", $noSession, $noSession/$total*100 );
2224 printf( "total: %-10d %6.2f%%\n", $total, 100 );

Status & tagging log