Issue #2201615 by hgoto: locale_translate_edit_form_submit() should check is_string(), instead of !empty() for string
parent
4a4f50448f
commit
bbb3a197d2
|
@ -1194,7 +1194,7 @@ function locale_translate_edit_form_submit($form, &$form_state) {
|
|||
$translation = db_query("SELECT translation FROM {locales_target} WHERE lid = :lid AND language = :language", array(':lid' => $lid, ':language' => $key))->fetchField();
|
||||
if (!empty($value)) {
|
||||
// Only update or insert if we have a value to use.
|
||||
if (!empty($translation)) {
|
||||
if (is_string($translation)) {
|
||||
db_update('locales_target')
|
||||
->fields(array(
|
||||
'translation' => $value,
|
||||
|
|
|
@ -393,6 +393,16 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
|
|||
// The indicator should not be here.
|
||||
$this->assertNoRaw($language_indicator, 'String is translated.');
|
||||
|
||||
// Verify that a translation set which has an empty target string can be
|
||||
// updated without any database error.
|
||||
db_update('locales_target')
|
||||
->fields(array('translation' => ''))
|
||||
->condition('language', $langcode, '=')
|
||||
->condition('lid', $lid, '=')
|
||||
->execute();
|
||||
$this->drupalPost('admin/config/regional/translate/edit/' . $lid, $edit, t('Save translations'));
|
||||
$this->assertText(t('The string has been saved.'), 'The string has been saved.');
|
||||
|
||||
// Try to edit a non-existent string and ensure we're redirected correctly.
|
||||
// Assuming we don't have 999,999 strings already.
|
||||
$random_lid = 999999;
|
||||
|
|
Loading…
Reference in New Issue