Index: drupal-6.x-dev/includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.198
diff -u -p -r1.198 bootstrap.inc
--- drupal-6.x-dev/includes/bootstrap.inc 25 Oct 2007 15:38:24 -0000 1.198
+++ drupal-6.x-dev/includes/bootstrap.inc 10 Nov 2007 11:09:31 -0000
@@ -831,7 +831,7 @@ function drupal_is_denied($type, $mask)
// these, we return 1 (denied). If no matching records or only ones
// with status = 1, we get no return from db_result, so we return
// (bool)NULL = 0 (allowed).
- return (bool) db_result(db_query_range("SELECT 1 FROM {access} WHERE type = '%s' AND LOWER('%s') LIKE LOWER(mask) AND status = 0", $type, $mask, 0, 1));
+ return (bool) db_result(db_query_range("SELECT 1 FROM {access} WHERE type = '%s' AND LOWER('%s') LIKE mask AND status = 0", $type, $mask, 0, 1));
}
/**
Index: drupal-6.x-dev/modules/user/user.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v
retrieving revision 1.9
diff -u -p -r1.9 user.admin.inc
--- drupal-6.x-dev/modules/user/user.admin.inc 10 Nov 2007 10:15:21 -0000 1.9
+++ drupal-6.x-dev/modules/user/user.admin.inc 10 Nov 2007 11:09:31 -0000
@@ -722,7 +722,7 @@ function user_admin_access_add($mask = N
form_set_error('mask', t('You must enter a mask.'));
}
else {
- db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $edit['mask'], $edit['type'], $edit['status']);
+ db_query("INSERT INTO {access} (mask, type, status) VALUES (LOWER('%s'), '%s', %d)", $edit['mask'], $edit['type'], $edit['status']);
$aid = db_last_insert_id('access', 'aid');
drupal_set_message(t('The access rule has been added.'));
drupal_goto('admin/user/rules');
@@ -744,7 +744,7 @@ function user_admin_access_edit($aid = 0
form_set_error('mask', t('You must enter a mask.'));
}
else {
- db_query("UPDATE {access} SET mask = '%s', type = '%s', status = '%s' WHERE aid = %d", $edit['mask'], $edit['type'], $edit['status'], $aid);
+ db_query("UPDATE {access} SET mask = LOWER('%s'), type = '%s', status = '%s' WHERE aid = %d", $edit['mask'], $edit['type'], $edit['status'], $aid);
drupal_set_message(t('The access rule has been saved.'));
drupal_goto('admin/user/rules');
}
@@ -780,7 +780,7 @@ function user_admin_access_form(&$form_s
'#size' => 30,
'#maxlength' => 64,
'#default_value' => $edit['mask'],
- '#description' => '%: '. t('Matches any number of characters, even zero characters') .'.
_: '. t('Matches exactly one character.'),
+ '#description' => '%: '. t('Matches any number of characters, even zero characters.') .'
_: '. t('Matches exactly one character.') . '
' . t('NOTE: For performance reasons, Drupal stores access rules in lower case.'),
'#required' => TRUE,
);
$form['submit'] = array('#type' => 'submit', '#value' => $submit);
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 10 Nov 2007 11:09:32 -0000
@@ -18,7 +18,7 @@ function user_schema() {
'length' => 255,
'not null' => TRUE,
'default' => '',
- 'description' => t('Text mask used for filtering access.'),
+ 'description' => t('Text mask used for filtering access. NOTE: For performance reasons, Drupal stores access rules in lower case.'),
),
'type' => array(
'type' => 'varchar',
@@ -36,6 +36,10 @@ function user_schema() {
),
),
'primary key' => array('aid'),
+ 'indexes' => array(
+ 'mask' => array('mask'),
+ 'type' => array('type')
+ ),
);
$schema['authmap'] = array(
@@ -282,3 +286,13 @@ function user_schema() {
return $schema;
}
+/**
+ * Add an index to access table and convert all stored masks to lower case.
+ */
+function user_update_6000() {
+ $ret = array();
+ db_add_index($ret, 'access', 'mask', array('mask'));
+ db_add_index($ret, 'access', 'type', array('type'));
+ $ret[] = update_sql('UPDATE {access} SET mask = LOWER(mask)');
+ 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 10 Nov 2007 11:09:32 -0000
@@ -2075,7 +2075,7 @@ function user_block_user_action(&$object
*/
function user_block_ip_action() {
$ip = ip_address();
- db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $ip, 'host', 0);
+ db_query("INSERT INTO {access} (mask, type, status) VALUES (LOWER('%s'), '%s', %d)", $ip, 'host', 0);
watchdog('action', 'Banned IP address %ip', array('%ip' => $ip));
}