Index: connectors/l10n_localpacks/l10n_localpacks.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/connectors/l10n_localpacks/Attic/l10n_localpacks.module,v retrieving revision 1.1.2.9.2.6 diff -u -p -r1.1.2.9.2.6 l10n_localpacks.module --- connectors/l10n_localpacks/l10n_localpacks.module 18 Sep 2009 18:03:18 -0000 1.1.2.9.2.6 +++ connectors/l10n_localpacks/l10n_localpacks.module 11 Jan 2010 18:12:45 -0000 @@ -236,7 +236,7 @@ function l10n_localpacks_save_data($proj } else { // Log error on existing project with another connector and skip the rest of this function. - $t_args = array('%uri' => $uri, '%other_connector' => $existing_project->connector_module, '%this_connector' => 'l10n_localpacks'); + $t_args = array('%uri' => $project_uri, '%other_connector' => $existing_project->connector_module, '%this_connector' => 'l10n_localpacks'); watchdog('l10n_localpacks', 'An existing project under the URI %uri is already handled by the %other_connector module. Not possible to add it with %this_connector.', $t_args); drupal_set_message(t('An existing project under the URI %uri is already handled by the %other_connector module. Not possible to add it with %this_connector.', $t_args), 'error'); return; Index: l10n_community/extractor.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/extractor.inc,v retrieving revision 1.1.2.13.2.8 diff -u -p -r1.1.2.13.2.8 extractor.inc --- l10n_community/extractor.inc 22 Dec 2009 18:24:23 -0000 1.1.2.13.2.8 +++ l10n_community/extractor.inc 11 Jan 2010 18:12:45 -0000 @@ -204,10 +204,10 @@ function l10n_community_save_string($val // A \0 separator in the string means we deal with a string with plural variants. // Unlike Drupal core, we store all in the same string, as it is easier // to handle later, and we don't need the individual string parts. - if (!$sid = db_result(db_query("SELECT sid FROM {l10n_community_string} WHERE value = BINARY '%s' AND context = '%s'", $value, $context))) { + if (!$sid = db_result(db_query("SELECT sid FROM {l10n_community_string} WHERE hashkey = MD5('%s')", $value . $context))) { // String does not exist. - db_query("INSERT INTO {l10n_community_string} (value, context) VALUES ('%s', '%s')", $value, $context); - $sid = db_result(db_query("SELECT sid FROM {l10n_community_string} WHERE value = BINARY '%s' AND context = '%s'", $value, $context)); + db_query("INSERT INTO {l10n_community_string} (value, context, hashkey) VALUES ('%s', '%s', MD5('%s'))", $value, $context, $value . $context); + $sid = db_result(db_query("SELECT sid FROM {l10n_community_string} WHERE hashkey = MD5('%s')", $value . $context)); } if (!db_result(db_query("SELECT fid FROM {l10n_community_line} WHERE fid = %d AND sid = %d AND lineno = %d AND type = %d", $fid, $sid, $line, $string_type))) { // Location does not exist with this string. Index: l10n_community/import.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/import.inc,v retrieving revision 1.1.2.5.2.17 diff -u -p -r1.1.2.5.2.17 import.inc --- l10n_community/import.inc 27 Dec 2009 08:08:51 -0000 1.1.2.5.2.17 +++ l10n_community/import.inc 11 Jan 2010 18:12:46 -0000 @@ -369,7 +369,7 @@ function _l10n_community_import_one_stri // We use BINARY matching here to avoid case insensitively matching // strings like 'operations' and 'Operations'. - if ($sid = db_result(db_query("SELECT sid FROM {l10n_community_string} WHERE BINARY value = '%s' AND context = '%s'", $value['msgid'], $value['msgctxt']))) { + if ($sid = db_result(db_query("SELECT sid FROM {l10n_community_string} WHERE hashkey = MD5('%s')", $value['msgid'] . $value['msgctxt']))) { // We have this source string (otherwise we don't save anything). $translation = db_fetch_object(db_query("SELECT translation FROM {l10n_community_translation} WHERE sid = %d AND language = '%s' AND is_suggestion = 0 AND is_active = 1", $sid, $langcode)); Index: l10n_community/l10n_community.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/l10n_community.install,v retrieving revision 1.1.2.11.2.14 diff -u -p -r1.1.2.11.2.14 l10n_community.install --- l10n_community/l10n_community.install 5 Dec 2009 13:50:38 -0000 1.1.2.11.2.14 +++ l10n_community/l10n_community.install 11 Jan 2010 18:12:46 -0000 @@ -266,8 +266,17 @@ function l10n_community_schema() { 'default' => '', 'description' => 'The context this string applies to. Only applicable to some strings in Drupal 7 and its modules.', ), + 'hashkey' => array( + 'description' => 'MD5 hash of the concatenation of value and context, used for quick lookups when these two are known (imports, new releases, remote submissions).', + 'type' => 'char', + 'length' => 32, + 'not null' => TRUE + ), ), 'primary key' => array('sid'), + 'unique keys' => array( + 'hashkey' => array('hashkey'), + ), ); $schema['l10n_community_translation'] = array( @@ -615,3 +624,16 @@ function l10n_community_update_6009() { } return $ret; } + +/** + * Add hashkey to speed up source string lookups. + */ +function l10n_community_update_6010() { + $ret = array(); + + db_add_field($ret, 'l10n_community_string', 'hashkey', array('type' => 'char', 'not null' => FALSE, 'length' => 32)); + $ret[] = update_sql("UPDATE {l10n_community_string} SET hashkey = MD5(CONCAT(value, context))"); + db_add_unique_key($ret, 'l10n_community_string', 'hashkey', array('hashkey')); + + return $ret; +} Index: l10n_remote/l10n_remote.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_remote/Attic/l10n_remote.module,v retrieving revision 1.1.2.6 diff -u -p -r1.1.2.6 l10n_remote.module --- l10n_remote/l10n_remote.module 27 Dec 2009 08:08:51 -0000 1.1.2.6 +++ l10n_remote/l10n_remote.module 11 Jan 2010 18:12:46 -0000 @@ -158,7 +158,8 @@ function l10n_remote_xmlrpc_string_submi // Check whether we have this source string managed. // @todo: add context support as soon as l10n_client starts to support it! - if (!($sid = db_result(db_query("SELECT sid FROM {l10n_community_string} WHERE BINARY value = '%s'", $source)))) { + // @todo: append $context to $source in MD5 counting when available. + if (!($sid = db_result(db_query("SELECT sid FROM {l10n_community_string} WHERE hashkey = MD5('%s')", $source)))) { //watchdog('l10n_community', 'Source string does not exist on server.', NULL, WATCHDOG_WARNING); return array('status' => FALSE, 'reason' => 'Source string not found on server, translation not saved.'); }