summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-04-20 02:23:17 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-04-20 02:23:17 +0000
commitd30a41e79147b29c22027e64fdf53e34d24bafe0 (patch)
tree67097bfe860bb00973225cb4213e19e6fcc9dc92
parent3b4e3d0334f36d76329d40ae5f8795287ec6a85e (diff)
downloadbrdo-d30a41e79147b29c22027e64fdf53e34d24bafe0.tar.gz
brdo-d30a41e79147b29c22027e64fdf53e34d24bafe0.tar.bz2
Roll-back of #333054; needs more discussion.
-rw-r--r--includes/database/mysql/schema.inc3
-rw-r--r--includes/database/pgsql/database.inc9
-rw-r--r--includes/database/sqlite/database.inc1
-rw-r--r--includes/image.inc3
-rw-r--r--modules/locale/locale.install6
-rw-r--r--modules/locale/locale.test15
-rw-r--r--modules/simpletest/tests/database_test.test28
-rw-r--r--modules/system/system.install33
-rw-r--r--modules/user/user.module6
9 files changed, 29 insertions, 75 deletions
diff --git a/includes/database/mysql/schema.inc b/includes/database/mysql/schema.inc
index abdbd0c59..b64e6040f 100644
--- a/includes/database/mysql/schema.inc
+++ b/includes/database/mysql/schema.inc
@@ -60,8 +60,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
*/
protected function createTableSql($name, $table) {
if (empty($table['mysql_suffix'])) {
- // Store strings as UTF-8 and do case-sensitive comparision.
- $table['mysql_suffix'] = 'DEFAULT CHARACTER SET UTF8 COLLATE utf8_bin';
+ $table['mysql_suffix'] = 'DEFAULT CHARACTER SET UTF8';
}
$sql = "CREATE TABLE {" . $name . "} (\n";
diff --git a/includes/database/pgsql/database.inc b/includes/database/pgsql/database.inc
index f329e2c23..c9dd63a06 100644
--- a/includes/database/pgsql/database.inc
+++ b/includes/database/pgsql/database.inc
@@ -97,8 +97,13 @@ class DatabaseConnection_pgsql extends DatabaseConnection {
}
public function mapConditionOperator($operator) {
- // We don't want to override any of the defaults.
- return NULL;
+ static $specials = array(
+ // In PostgreSQL, 'LIKE' is case-sensitive. For case-insensitive LIKE
+ // statements, we need to use ILIKE instead.
+ 'LIKE' => array('operator' => 'ILIKE'),
+ );
+
+ return isset($specials[$operator]) ? $specials[$operator] : NULL;
}
/**
diff --git a/includes/database/sqlite/database.inc b/includes/database/sqlite/database.inc
index e23bab852..e872f5c3c 100644
--- a/includes/database/sqlite/database.inc
+++ b/includes/database/sqlite/database.inc
@@ -31,7 +31,6 @@ class DatabaseConnection_sqlite extends DatabaseConnection {
));
$this->exec('PRAGMA encoding="UTF-8"');
- $this->exec('PRAGMA case_sensitive_like=1');
// Create functions needed by SQLite.
$this->sqliteCreateFunction('if', array($this, 'sqlFunctionIf'));
diff --git a/includes/image.inc b/includes/image.inc
index a1e674cc1..24e90dbf7 100644
--- a/includes/image.inc
+++ b/includes/image.inc
@@ -68,7 +68,8 @@ function image_get_toolkit() {
if (!isset($toolkits[$toolkit]) || !drupal_function_exists('image_' . $toolkit . '_load')) {
// The selected toolkit isn't available so return the first one found. If
// none are available this will return FALSE.
- $toolkit = reset($toolkits);
+ reset($toolkits);
+ $toolkit = key($toolkits);
}
}
diff --git a/modules/locale/locale.install b/modules/locale/locale.install
index 32d7d18d0..d9ef10afb 100644
--- a/modules/locale/locale.install
+++ b/modules/locale/locale.install
@@ -5,6 +5,10 @@
* Implementation of hook_install().
*/
function locale_install() {
+ // locales_source.source and locales_target.target are not used as binary
+ // fields; non-MySQL database servers need to ensure the field type is text
+ // and that LIKE produces a case-sensitive comparison.
+
// Create tables.
drupal_install_schema('locale');
@@ -350,6 +354,7 @@ function locale_schema() {
),
'source' => array(
'type' => 'text',
+ 'mysql_type' => 'blob',
'not null' => TRUE,
'description' => 'The original string in English.',
),
@@ -378,6 +383,7 @@ function locale_schema() {
),
'translation' => array(
'type' => 'text',
+ 'mysql_type' => 'blob',
'not null' => TRUE,
'description' => 'Translation string value in this language.',
),
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index 258eb5125..9e793dffb 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -391,9 +391,8 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
// This is the language indicator on the translation search screen for
// untranslated strings. Copied straight from locale.inc.
$language_indicator = "<em class=\"locale-untranslated\">$langcode</em> ";
- // This will be the translation of $name. Make sure it contains at least
- // one lower-case character in order to check case-sensitive search.
- $translation = $this->randomName(16) . 'x';
+ // This will be the translation of $name.
+ $translation = $this->randomName(16);
// Add custom language.
$this->drupalLogin($admin_user);
@@ -470,16 +469,6 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
$this->drupalPost('admin/international/translate/translate', $search, t('Filter'));
$this->assertNoText(t('No strings found for your search.'), t('Search found the translation.'));
- // Ensure string search is case-sensitive.
- $search = array(
- 'string' => drupal_strtoupper($translation),
- 'language' => 'all',
- 'translation' => 'translated',
- 'group' => 'all',
- );
- $this->drupalPost('admin/international/translate/translate', $search, t('Filter'));
- $this->assertText(t('No strings found for your search.'), t("Search didn't find the translation."));
-
// Ensure translated source string doesn't appear if searching on 'only
// untranslated strings'.
$search = array(
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index b0b299215..a59e321aa 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -1995,34 +1995,6 @@ class DatabaseRegressionTestCase extends DatabaseTestCase {
$this->assertTrue(db_table_exists('node'), t('Returns true for existent table.'));
$this->assertFalse(db_table_exists('nosuchtable'), t('Returns false for nonexistent table.'));
}
-
- /**
- * Test that string comparison is case-sensitive.
- */
- function testCaseSensitiviteCompare() {
- $num_matches = db_query("SELECT COUNT(*) FROM {test} WHERE name = :name", array(':name' => 'George'))->fetchField();
- $this->assertEqual($num_matches, 1, t('Correct number of records found with proper case.'));
- $num_matches = db_query("SELECT COUNT(*) FROM {test} WHERE name = :name", array(':name' => 'GEORGE'))->fetchField();
- $this->assertEqual($num_matches, 0, t('Correct number of records found with wrong case.'));
-
- $num_matches = db_query("SELECT COUNT(*) FROM {test} WHERE name LIKE :name", array(':name' => 'Geo%'))->fetchField();
- $this->assertEqual($num_matches, 1, t('Correct number of records found with proper case.'));
- $num_matches = db_query("SELECT COUNT(*) FROM {test} WHERE name LIKE :name", array(':name' => 'GEO%'))->fetchField();
- $this->assertEqual($num_matches, 0, t('Correct number of records found with wrong case.'));
-
- $num_matches = db_select('test')
- ->condition('name', 'Geo%', 'LIKE')
- ->countQuery()
- ->execute()
- ->fetchField();
- $this->assertEqual($num_matches, 1, t('Correct number of records found with proper case.'));
- $num_matches = db_select('test')
- ->condition('name', 'GEO%', 'LIKE')
- ->countQuery()
- ->execute()
- ->fetchField();
- $this->assertEqual($num_matches, 0, t('Correct number of records found with wrong case.'));
- }
}
/**
diff --git a/modules/system/system.install b/modules/system/system.install
index 3981cfdda..19908ee0d 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -3086,29 +3086,10 @@ function system_update_7011() {
}
/**
- * Make tables case-sensitive on MySQL.
- */
-function system_update_7012() {
- $ret = array();
- if (db_driver() == 'mysql') {
- // Table names as used in D6. Some have changed and are no longer reported
- // by hook_schema(). The list is generated using the following command:
- // grep -r "^ \+\$schema\['[a-z_]\+'\] =" modules | cut -d\' -f2 | sort -u | xargs -I '*' echo -n "'*', "
- $tables = array('access', 'accesslog', 'actions', 'actions_aid', 'aggregator_category', 'aggregator_category_feed', 'aggregator_category_item', 'aggregator_feed', 'aggregator_item', 'authmap', 'batch', 'blocks', 'blocks_roles', 'blogapi_files', 'book', 'book_temp', 'boxes', 'cache', 'cache_block', 'cache_filter', 'cache_form', 'cache_menu', 'cache_page', 'cache_update', 'comments', 'contact', 'files', 'filter_formats', 'filters', 'flood', 'forum', 'history', 'languages', 'locales_source', 'locales_target', 'menu_custom', 'menu_links', 'menu_router', 'node', 'node_access', 'node_comment_statistics', 'node_counter', 'node_revisions', 'node_type', 'openid_association', 'permission', 'poll', 'poll_choices', 'poll_votes', 'profile_fields', 'profile_values', 'role', 'search_dataset', 'search_index', 'search_node_links', 'search_total', 'sessions', 'system', 'term_data', 'term_hierarchy', 'term_node', 'term_relation', 'term_synonym', 'trigger_assignments', 'upload', 'url_alias', 'users', 'users_roles', 'variable', 'vocabulary', 'vocabulary_node_types', 'watchdog');
- foreach ($tables as $table) {
- if (db_table_exists($table)) {
- $ret[] = update_sql('ALTER TABLE {' . $table . '} CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin');
- }
- }
- }
- return $ret;
-}
-
-/**
* Rename {blocks} table to {block}, {blocks_roles} to {block_role} and
* {boxes} to {box}.
*/
-function system_update_7013() {
+function system_update_7012() {
$ret = array();
db_rename_table($ret, 'blocks', 'block');
db_rename_table($ret, 'blocks_roles', 'block_role');
@@ -3119,7 +3100,7 @@ function system_update_7013() {
/**
* Convert default time zone offset to default time zone name.
*/
-function system_update_7014() {
+function system_update_7013() {
$ret = array();
$timezone = NULL;
$timezones = system_time_zones();
@@ -3160,7 +3141,7 @@ function system_update_7014() {
/**
* Drop the bootstrap column from the {system} table.
*/
-function system_update_7015() {
+function system_update_7014() {
$ret = array();
db_drop_field($ret, 'system', 'bootstrap');
return $ret;
@@ -3169,7 +3150,7 @@ function system_update_7015() {
/**
* Change the user logout path.
*/
-function system_update_7016() {
+function system_update_7015() {
$ret = array();
$ret[] = update_sql("UPDATE {menu_links} SET link_path = 'user/logout' WHERE link_path = 'logout'");
$ret[] = update_sql("UPDATE {menu_links} SET router_path = 'user/logout' WHERE router_path = 'logout'");
@@ -3179,7 +3160,7 @@ function system_update_7016() {
/**
* Remove custom datatype *_unsigned in PostgreSQL.
*/
-function system_update_7017() {
+function system_update_7016() {
$ret = array();
// Only run these queries if the driver used is pgsql.
if (db_driver() == 'pgsql') {
@@ -3213,7 +3194,7 @@ function system_update_7017() {
/**
* Change the theme setting 'toggle_node_info' into a per content type variable.
*/
-function system_update_7018() {
+function system_update_7017() {
$ret = array();
$types = node_get_types();
if (count($types)) {
@@ -3242,7 +3223,7 @@ function system_update_7018() {
/**
* Shorten the {system}.type column and add an index on type and name.
*/
-function system_update_7019() {
+function system_update_7018() {
$ret = array();
db_drop_index($ret, 'system', 'modules');
db_change_field($ret, 'system', 'type', 'type', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
diff --git a/modules/user/user.module b/modules/user/user.module
index 37e88e5a5..1af5f6de9 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -216,12 +216,14 @@ function user_load_multiple($uids = array(), $conditions = array(), $reset = FAL
}
// If the conditions array is populated, add those to the query.
if ($conditions) {
+ // TODO D7: Using LIKE() to get a case insensitive comparison because Crell
+ // and chx promise that dbtng will map it to ILIKE in postgres.
if (isset($conditions['name'])) {
- $query->where('LOWER(u.name) = LOWER(:name)', array(':name' => $conditions['name']));
+ $query->condition('u.name', $conditions['name'], 'LIKE');
unset($conditions['name']);
}
if (isset($conditions['mail'])) {
- $query->where('LOWER(u.mail) = LOWER(:mail)', array(':mail' => $conditions['mail']));
+ $query->condition('u.mail', $conditions['mail'], 'LIKE');
unset($conditions['mail']);
}
foreach ($conditions as $field => $value) {