Sanity check on result from SHOW PROCESSLIST, foreach -> while (sorta followup to...
authorChad Horohoe <demon@users.mediawiki.org>
Tue, 28 Sep 2010 11:39:10 +0000 (11:39 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Tue, 28 Sep 2010 11:39:10 +0000 (11:39 +0000)
includes/db/DatabaseMysql.php

index afcaa2c..041ebd1 100644 (file)
@@ -321,8 +321,11 @@ class DatabaseMysql extends DatabaseBase {
                        return $this->mFakeSlaveLag;
                }
                $res = $this->query( 'SHOW PROCESSLIST', __METHOD__ );
+               if( !$res ) {
+                       return false;
+               }
                # Find slave SQL thread
-               while ( $row = $this->fetchObject( $res ) ) {
+               foreach( $res as $row ) {
                        /* This should work for most situations - when default db
                         * for thread is not specified, it had no events executed,
                         * and therefore it doesn't know yet how lagged it is.