 modules/dblog/dblog.admin.inc |   41 ++++++++++++++++-------------------------
 modules/dblog/dblog.test      |   20 ++++++++++++++++++++
 2 files changed, 36 insertions(+), 25 deletions(-)

diff --git modules/dblog/dblog.admin.inc modules/dblog/dblog.admin.inc
index 6d3524d..16d93f1 100644
--- modules/dblog/dblog.admin.inc
+++ modules/dblog/dblog.admin.inc
@@ -13,7 +13,6 @@
  * the message details page.
  */
 function dblog_overview() {
-  $filter = dblog_build_filter_query();
   $rows = array();
   $icons = array(
     WATCHDOG_DEBUG     => '',
@@ -49,14 +48,11 @@ function dblog_overview() {
   );
 
   $query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort');
+  dblog_build_filter_query($query);
   $query->leftJoin('users', 'u', 'w.uid = u.uid');
-  $query
-    ->fields('w', array('wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables', 'link'))
-    ->addField('u', 'name');
-  if (!empty($filter['where'])) {
-    $query->where($filter['where'], $filter['args']);
-  }
   $result = $query
+    ->fields('w', array('wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables', 'link'))
+    ->fields('u', array('name'))
     ->limit(50)
     ->orderByHeader($header)
     ->execute();
@@ -64,7 +60,7 @@ function dblog_overview() {
   foreach ($result as $dblog) {
     $rows[] = array('data' =>
       array(
-        // Cells
+        // Cells.
         $icons[$dblog->severity],
         t($dblog->type),
         format_date($dblog->timestamp, 'short'),
@@ -72,7 +68,7 @@ function dblog_overview() {
         theme('username', array('account' => $dblog)),
         $dblog->link,
       ),
-      // Attributes for tr
+      // Attributes for table row.
       'class' => array(drupal_html_class('dblog-' . $dblog->type), $classes[$dblog->severity]),
     );
   }
@@ -194,8 +190,12 @@ function dblog_event($id) {
 
 /**
  * Build query for dblog administration filters based on session.
+ *
+ * @param $query
+ *   A SelectQuery object for the watchdog table.
+ * @see dblog_overview()
  */
-function dblog_build_filter_query() {
+function dblog_build_filter_query(SelectQueryInterface $query) {
   if (empty($_SESSION['dblog_overview_filter'])) {
     return;
   }
@@ -203,26 +203,17 @@ function dblog_build_filter_query() {
   $filters = dblog_filters();
 
   // Build query
-  $where = $args = array();
   foreach ($_SESSION['dblog_overview_filter'] as $key => $filter) {
-    $filter_where = array();
+    $filter_where = db_or();
     foreach ($filter as $value) {
-      $filter_where[] = $filters[$key]['where'];
-      $args[] = $value;
+      $filter_where->condition($filters[$key]['where'], $value);
     }
-    if (!empty($filter_where)) {
-      $where[] = '(' . implode(' OR ', $filter_where) . ')';
+    if (count($filter_where) > 0) {
+      $query->condition($filter_where);
     }
   }
-  $where = !empty($where) ? implode(' AND ', $where) : '';
-
-  return array(
-    'where' => $where,
-    'args' => $args,
-  );
 }
 
-
 /**
  * List dblog administration filters that can be applied.
  */
@@ -236,14 +227,14 @@ function dblog_filters() {
   if (!empty($types)) {
     $filters['type'] = array(
       'title' => t('Type'),
-      'where' => "w.type = ?",
+      'where' => 'w.type',
       'options' => $types,
     );
   }
 
   $filters['severity'] = array(
     'title' => t('Severity'),
-    'where' => 'w.severity = ?',
+    'where' => 'w.severity',
     'options' => watchdog_severity_levels(),
   );
 
diff --git modules/dblog/dblog.test modules/dblog/dblog.test
index f9048f0..e5260cb 100644
--- modules/dblog/dblog.test
+++ modules/dblog/dblog.test
@@ -455,6 +455,26 @@ class DBLogTestCase extends DrupalWebTestCase {
       $this->assertEqual(array_sum($count), $type_count, 'Count matched');
     }
 
+    // Filter on two different types.
+    $type_name1 = $type_names[0];
+    $type_name2 = $type_names[1];
+    $edit = array(
+      'type[]' => array($type_name1, $type_name2),
+    );
+    $this->drupalPost(NULL, $edit, t('Filter'));
+
+    // Count the number of entries of this type.
+    $type_count = 0;
+    foreach ($types as $type) {
+      if ($type['type'] == $type_name1 || $type['type'] == $type_name2) {
+        $type_count += $type['count'];
+      }
+    }
+
+    // Compare expected and actual values.
+    $count = $this->getTypeCount($types);
+    $this->assertEqual(array_sum($count), $type_count, 'Count matched for two conditions');
+
     // Set filter to match each of the three type attributes and confirm the
     // number of entries displayed.
     foreach ($types as $key => $type) {
