From 7fb11ef6a91857ff37184487a994ea0017835d67 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sat, 12 Feb 2011 09:14:11 -0500
Subject: [PATCH] Move BINARY modifier to make MYSQL use index again

---
 program/include/rcube_user.php |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php
index ee6db77..ba56135 100644
--- a/program/include/rcube_user.php
+++ b/program/include/rcube_user.php
@@ -5,7 +5,7 @@
  | program/include/rcube_user.inc                                        |
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
- | Copyright (C) 2005-2010, Roundcube Dev. - Switzerland                 |
+ | Copyright (C) 2005-2010, The Roundcube Dev Team                       |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
  | PURPOSE:                                                              |
@@ -359,12 +359,11 @@
         $dbh = rcmail::get_instance()->get_dbh();
 
         // use BINARY (case-sensitive) comparison on MySQL, other engines are case-sensitive
-        $prefix = preg_match('/^mysql/', $dbh->db_provider) ? 'BINARY ' : '';
+        $mod = preg_match('/^mysql/', $dbh->db_provider) ? 'BINARY' : '';
 
         // query for matching user name
-        $query = "SELECT * FROM ".get_table_name('users')." WHERE mail_host = ? AND %s = ?";
-
-        $sql_result = $dbh->query(sprintf($query, $prefix.'username'), $host, $user);
+        $query = "SELECT * FROM ".get_table_name('users')." WHERE mail_host = ? AND username = $mod ?";
+        $sql_result = $dbh->query($query, $host, $user);
 
         // query for matching alias
         if (!($sql_arr = $dbh->fetch_assoc($sql_result))) {

--
Gitblit v1.9.1