diff options
author | Dries Buytaert <dries@buytaert.net> | 2006-05-16 09:22:36 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2006-05-16 09:22:36 +0000 |
commit | 3d38b57220a6302f34d31b332c1b680569493ab9 (patch) | |
tree | 7c35a1a4d40bfeec3569d4ca3efbd47e854924b4 | |
parent | 2d9eaf01cf87f56f5b159ac25c588097316dd74f (diff) | |
download | brdo-3d38b57220a6302f34d31b332c1b680569493ab9.tar.gz brdo-3d38b57220a6302f34d31b332c1b680569493ab9.tar.bz2 |
- Patch #41481 by Zen, Cvbge, sun et al: bugfix: duplicate key error while editing locale strings.
-rw-r--r-- | database/database.pgsql | 4 | ||||
-rw-r--r-- | database/updates.inc | 16 | ||||
-rw-r--r-- | includes/locale.inc | 11 | ||||
-rw-r--r-- | includes/xmlrpc.inc | 4 | ||||
-rw-r--r-- | modules/system.module | 2 | ||||
-rw-r--r-- | modules/system/system.module | 2 |
6 files changed, 28 insertions, 11 deletions
diff --git a/database/database.pgsql b/database/database.pgsql index c2449b591..4729a99eb 100644 --- a/database/database.pgsql +++ b/database/database.pgsql @@ -378,9 +378,9 @@ CREATE TABLE locales_target ( translation text DEFAULT '' NOT NULL, locale varchar(12) NOT NULL default '', plid int4 NOT NULL default '0', - plural int4 NOT NULL default '0', - UNIQUE (lid) + plural int4 NOT NULL default '0' ); +CREATE INDEX locales_target_lid_idx ON locales_target(lid); CREATE INDEX locales_target_locale_idx ON locales_target(locale); CREATE INDEX locales_target_plid_idx ON locales_target(plid); CREATE INDEX locales_target_plural_idx ON locales_target(plural); diff --git a/database/updates.inc b/database/updates.inc index a854e97ce..e6c1874aa 100644 --- a/database/updates.inc +++ b/database/updates.inc @@ -1218,7 +1218,7 @@ function system_update_159() { case 'mysql': $ret[] = update_sql("UPDATE {sequences} SET id = $vid WHERE name = '{node_revisions}_vid'"); break; - + case 'pgsql': $ret[] = update_sql("SELECT setval('{node_revisions}_vid_seq', $vid)"); break; @@ -1993,3 +1993,17 @@ function system_update_181() { } return $ret; } + +/** + * The lid field in pgSQL should not be UNIQUE, but an INDEX. + */ +function system_update_182() { + $ret = array(); + + if ($GLOBALS['db_type'] == 'pgsql') { + $ret[] = update_sql('ALTER TABLE {locales_target} DROP CONSTRAINT {locales_target}_lid_idx'); + $ret[] = update_sql('CREATE INDEX {locales_target}_lid_idx ON {locales_target} (lid)'); + } + + return $ret; +} diff --git a/includes/locale.inc b/includes/locale.inc index 1d80d9c61..027e838a2 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -358,13 +358,15 @@ function _locale_string_edit($lid) { $result = db_query('SELECT DISTINCT s.source, t.translation, t.locale FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid WHERE s.lid = %d', $lid); $form = array(); + $form['translations'] = array('#tree' => TRUE); while ($translation = db_fetch_object($result)) { $orig = $translation->source; // Approximate the number of rows in a textfield with a maximum of 10. $rows = min(ceil(str_word_count($orig) / 12), 10); - $form[$translation->locale] = array('#type' => 'textarea', + $form['translations'][$translation->locale] = array( + '#type' => 'textarea', '#title' => $languages['name'][$translation->locale], '#default_value' => $translation->translation, '#rows' => $rows, @@ -386,7 +388,8 @@ function _locale_string_edit($lid) { ); foreach ($languages['name'] as $key => $lang) { - $form[$key] = array('#type' => 'textarea', + $form['translations'][$key] = array( + '#type' => 'textarea', '#title' => $lang, '#rows' => $rows, ); @@ -404,14 +407,14 @@ function _locale_string_edit($lid) { */ function _locale_string_edit_submit($form_id, $form_values) { $lid = $form_values['lid']; - foreach ($form_values as $key => $value) { + foreach ($form_values['translations'] as $key => $value) { $value = filter_xss_admin($value); $trans = db_fetch_object(db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND locale = '%s'", $lid, $key)); if (isset($trans->translation)) { db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND locale = '%s'", $value, $lid, $key); } else { - db_query("INSERT INTO {locales_target} (lid, translation, locale) VALUES (%d, '%s', '%s')", $lid, $value, $key); + db_query("INSERT INTO {locales_target} (lid, translation, locale) VALUES (%d, '%s', '%s')", $lid, $value, $key); } } drupal_set_message(t('The string has been saved.')); diff --git a/includes/xmlrpc.inc b/includes/xmlrpc.inc index 4db993798..2c37f36b5 100644 --- a/includes/xmlrpc.inc +++ b/includes/xmlrpc.inc @@ -417,9 +417,9 @@ function xmlrpc_base64_get_xml($xmlrpc_base64) { } /** - * Execute an XML remote procedural call. This is private function; call xmlrpc() + * Execute an XML remote procedural call. This is private function; call xmlrpc() * in common.inc instead of this functino. - * + * * @return * A $xmlrpc_message object if the call succeeded; FALSE if the call failed */ diff --git a/modules/system.module b/modules/system.module index 17aa467bc..be43aace4 100644 --- a/modules/system.module +++ b/modules/system.module @@ -73,7 +73,7 @@ function system_elements() { $type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes' => array()), '#tree' => TRUE); $type['select'] = array('#input' => TRUE); $type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('process_weight' => array())); - $type['date'] = array('#input' => TRUE, '#process' => array('expand_date' => array())); + $type['date'] = array('#input' => TRUE, '#process' => array('expand_date' => array()), '#validate' => array('date_validate' => array())); $type['file'] = array('#input' => TRUE, '#size' => 60); // Form structure diff --git a/modules/system/system.module b/modules/system/system.module index 17aa467bc..be43aace4 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -73,7 +73,7 @@ function system_elements() { $type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes' => array()), '#tree' => TRUE); $type['select'] = array('#input' => TRUE); $type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('process_weight' => array())); - $type['date'] = array('#input' => TRUE, '#process' => array('expand_date' => array())); + $type['date'] = array('#input' => TRUE, '#process' => array('expand_date' => array()), '#validate' => array('date_validate' => array())); $type['file'] = array('#input' => TRUE, '#size' => 60); // Form structure |