? drupal-6.x-dev/sites/default/settings.php Index: drupal-6.x-dev/modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.175 diff -u -p -r1.175 system.install --- drupal-6.x-dev/modules/system/system.install 11 Nov 2007 08:48:22 -0000 1.175 +++ drupal-6.x-dev/modules/system/system.install 13 Nov 2007 07:13:29 -0000 @@ -268,7 +268,7 @@ function system_install() { // presumed to be a serialized array. Install will change uid 1 immediately // anyways. So we insert the superuser here, the uid is 2 here for now, but // very soon it will be changed to 1. - db_query("INSERT INTO {users} (name, mail, created, data) VALUES('%s', '%s', %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', time(), serialize(array())); + db_query("INSERT INTO {users} (name, name_lower, mail, created, data) VALUES('%s', '%s', '%s', %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', 'placeholder-for-uid-1', time(), serialize(array())); // This sets the above two users to 1 -1 = 0 (anonymous) and // 2- 1 = 1 (superuser). We skip uid 2 but that's not a big problem. db_query('UPDATE {users} SET uid = uid - 1'); Index: drupal-6.x-dev/modules/taxonomy/taxonomy.install =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.install,v retrieving revision 1.4 diff -u -p -r1.4 taxonomy.install --- drupal-6.x-dev/modules/taxonomy/taxonomy.install 21 Oct 2007 18:59:02 -0000 1.4 +++ drupal-6.x-dev/modules/taxonomy/taxonomy.install 13 Nov 2007 07:13:29 -0000 @@ -28,6 +28,13 @@ function taxonomy_schema() { 'default' => '', 'description' => t('The term name.'), ), + 'name_lower' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + 'description' => t('The term name in lowercase.'), + ), 'description' => array( 'type' => 'text', 'not null' => FALSE, @@ -43,7 +50,10 @@ function taxonomy_schema() { ), ), 'primary key' => array('tid'), - 'indexes' => array('vid' => array('vid')), + 'indexes' => array( + 'vid' => array('vid'), + 'name_lower' => array('name_lower') + ), ); $schema['term_hierarchy'] = array( @@ -274,3 +284,14 @@ function taxonomy_schema() { return $schema; } +/** + * Add a name_lower field to term_data table, folk from name, and convert it to + * lower case. + */ +function taxonomy_update_6000() { + $ret = array(); + db_add_field($ret, 'term_data', 'name_lower', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => t('The term name in lowercase.'))); + $ret[] = update_sql('UPDATE {term_data} SET name_lower = LOWER(name)'); + db_add_unique_key($ret, 'term_data', 'name_lower', array('name_lower')); + return $ret; +} Index: drupal-6.x-dev/modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.389 diff -u -p -r1.389 taxonomy.module --- drupal-6.x-dev/modules/taxonomy/taxonomy.module 11 Nov 2007 06:56:44 -0000 1.389 +++ drupal-6.x-dev/modules/taxonomy/taxonomy.module 13 Nov 2007 07:13:30 -0000 @@ -238,6 +238,7 @@ function taxonomy_save_term(&$form_value if (!empty($form_values['tid']) && $form_values['name']) { drupal_write_record('term_data', $form_values, 'tid'); + db_query("UPDATE {term_data} SET name_lower = LOWER(name) WHERE tid = %d", $form_values['tid']); $hook = 'update'; $status = SAVED_UPDATED; } @@ -246,6 +247,7 @@ function taxonomy_save_term(&$form_value } else { drupal_write_record('term_data', $form_values); + db_query("UPDATE {term_data} SET name_lower = LOWER(name) WHERE tid = %d", $form_values['tid']); $hook = 'insert'; $status = SAVED_NEW; } @@ -832,7 +834,7 @@ function _taxonomy_term_children($tid) { * An array of matching term objects. */ function taxonomy_get_term_by_name($name) { - $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER(t.name) LIKE LOWER('%s')", 't', 'tid'), trim($name)); + $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE t.name_lower LIKE LOWER('%s')", 't', 'tid'), trim($name)); $result = array(); while ($term = db_fetch_object($db_result)) { $result[] = $term; Index: drupal-6.x-dev/modules/user/user.install =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.install,v retrieving revision 1.3 diff -u -p -r1.3 user.install --- drupal-6.x-dev/modules/user/user.install 4 Nov 2007 14:33:07 -0000 1.3 +++ drupal-6.x-dev/modules/user/user.install 13 Nov 2007 07:13:30 -0000 @@ -142,6 +142,13 @@ function user_schema() { 'default' => '', 'description' => t('Unique user name.'), ), + 'name_lower' => array( + 'type' => 'varchar', + 'length' => 60, + 'not null' => TRUE, + 'default' => '', + 'description' => t('User name in lowercase.'), + ), 'pass' => array( 'type' => 'varchar', 'length' => 32, @@ -254,7 +261,10 @@ function user_schema() { 'access' => array('access'), 'created' => array('created') ), - 'unique keys' => array('name' => array('name')), + 'unique keys' => array( + 'name' => array('name'), + 'name_lower' => array('name_lower') + ), 'primary key' => array('uid'), ); @@ -282,3 +292,14 @@ function user_schema() { return $schema; } +/** + * Add a name_lower field to users table, folk from name, and convert it to + * lower case. + */ +function user_update_6000() { + $ret = array(); + db_add_field($ret, 'users', 'name_lower', array('type' => 'varchar', 'length' => 60, 'not null' => TRUE, 'default' => '', 'description' => t('User name in lowercase.'))); + $ret[] = update_sql('UPDATE {users} SET name_lower = LOWER(name)'); + db_add_unique_key($ret, 'users', 'name_lower', array('name_lower')); + return $ret; +} Index: drupal-6.x-dev/modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.862 diff -u -p -r1.862 user.module --- drupal-6.x-dev/modules/user/user.module 6 Nov 2007 12:20:14 -0000 1.862 +++ drupal-6.x-dev/modules/user/user.module 13 Nov 2007 07:13:30 -0000 @@ -144,17 +144,23 @@ function user_load($array = array()) { } foreach ($array as $key => $value) { - if ($key == 'uid' || $key == 'status') { - $query[] = "$key = %d"; - $params[] = $value; - } - else if ($key == 'pass') { - $query[] = "pass = '%s'"; - $params[] = md5($value); - } - else { - $query[]= "LOWER($key) = LOWER('%s')"; - $params[] = $value; + switch ($key) { + case 'uid': + case 'status': + $query[] = "$key = %d"; + $params[] = $value; + break; + case 'pass': + $query[] = "pass = '%s'"; + $params[] = md5($value); + break; + case 'name': + $query[]= "name_lower = LOWER('%s')"; + $params[] = $value; + break; + default: + $query[]= "LOWER($key) = LOWER('%s')"; + $params[] = $value; } } $result = db_query('SELECT * FROM {users} u WHERE '. implode(' AND ', $query), $params); @@ -216,6 +222,10 @@ function user_save($account, $array = ar else if ((substr($key, 0, 4) !== 'auth') && ($key != 'pass')) { if (in_array($key, $user_fields)) { // Save standard fields + if ($key == 'name') { + $query .= "name_lower = LOWER('%s'), "; + $v[] = $value; + } $query .= "$key = '%s', "; $v[] = $value; } @@ -297,6 +307,14 @@ function user_save($account, $array = ar $values[] = $value; $s[] = "%d"; break; + case 'name': + $fields[] = $key; + $values[] = $value; + $s[] = "'%s'"; + $fields[] = 'name_lower'; + $values[] = $value; + $s[] = "LOWER('%s')"; + break; default: if (substr($key, 0, 4) !== 'auth' && in_array($key, $user_fields)) { $fields[] = $key; @@ -489,7 +507,7 @@ function user_access($string, $account = * @return boolean TRUE for blocked users, FALSE for active */ function user_is_blocked($name) { - $deny = db_fetch_object(db_query("SELECT name FROM {users} WHERE status = 0 AND name = LOWER('%s')", $name)); + $deny = db_fetch_object(db_query("SELECT name FROM {users} WHERE status = 0 AND name_lower = LOWER('%s')", $name)); return $deny; }