Check for boolean false result from database query in SqlBagOStuff
authorOri Livneh <ori@wikimedia.org>
Tue, 24 Jun 2014 02:11:51 +0000 (19:11 -0700)
committerumherirrender <umherirrender_de.wp@web.de>
Mon, 21 Jul 2014 13:13:31 +0000 (15:13 +0200)
Database::select() can return false, so we should check for it before
attempting to iterate on the result or to call methods on it.

Change-Id: I0862493305e5b2784422e0e94b3e62e734267795

includes/objectcache/SqlBagOStuff.php

index 0c91dab..7157e79 100644 (file)
@@ -244,6 +244,9 @@ class SqlBagOStuff extends BagOStuff {
                                                // We do not want to flush the TRX as that can break callers.
                                                $db->trxLevel() ? array( 'LOCK IN SHARE MODE' ) : array()
                                        );
+                                       if ( $res === false ) {
+                                               continue;
+                                       }
                                        foreach ( $res as $row ) {
                                                $row->serverIndex = $serverIndex;
                                                $row->tableName = $tableName;
@@ -579,7 +582,7 @@ class SqlBagOStuff extends BagOStuff {
                                                        $conds,
                                                        __METHOD__,
                                                        array( 'LIMIT' => 100, 'ORDER BY' => 'exptime' ) );
-                                               if ( !$rows->numRows() ) {
+                                               if ( $rows === false || !$rows->numRows() ) {
                                                        break;
                                                }
                                                $keys = array();