diff options
author | Dries Buytaert <dries@buytaert.net> | 2011-05-01 06:31:39 -0400 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2011-05-01 06:31:39 -0400 |
commit | 400284fb2cb1bc261120874fd000868ef50e5aaf (patch) | |
tree | 3343a6f6aad37d810b8d1f76a03f9b9a97fdb80b /modules/locale | |
parent | 3f154706a3da1084b304cfc0b36fa375471e2f19 (diff) | |
download | brdo-400284fb2cb1bc261120874fd000868ef50e5aaf.tar.gz brdo-400284fb2cb1bc261120874fd000868ef50e5aaf.tar.bz2 |
- Patch #1099396 by Désiré, droplet, plach: language_count() is never decremented when removing a language.
Diffstat (limited to 'modules/locale')
-rw-r--r-- | modules/locale/locale.admin.inc | 3 | ||||
-rw-r--r-- | modules/locale/locale.install | 8 | ||||
-rw-r--r-- | modules/locale/locale.test | 27 |
3 files changed, 37 insertions, 1 deletions
diff --git a/modules/locale/locale.admin.inc b/modules/locale/locale.admin.inc index 3e4c6f188..de16133fb 100644 --- a/modules/locale/locale.admin.inc +++ b/modules/locale/locale.admin.inc @@ -467,6 +467,9 @@ function locale_languages_delete_form_submit($form, &$form_state) { ->fields(array('language' => '')) ->condition('language', $form_state['values']['langcode']) ->execute(); + if ($languages[$form_state['values']['langcode']]->enabled) { + variable_set('language_count', variable_get('language_count', 1) - 1); + } module_invoke_all('multilingual_settings_changed'); $variables = array('%locale' => $languages[$form_state['values']['langcode']]->name); drupal_set_message(t('The language %locale has been removed.', $variables)); diff --git a/modules/locale/locale.install b/modules/locale/locale.install index 2abbc53c1..80b20c454 100644 --- a/modules/locale/locale.install +++ b/modules/locale/locale.install @@ -126,6 +126,14 @@ function locale_update_7002() { } /** + * Update "language_count" variable. + */ +function locale_update_7003() { + $languages = language_list('enabled'); + variable_set('language_count', count($languages[1])); +} + +/** * @} End of "addtogroup updates-6.x-to-7.x" */ diff --git a/modules/locale/locale.test b/modules/locale/locale.test index 765bfb6dd..5e9e8336c 100644 --- a/modules/locale/locale.test +++ b/modules/locale/locale.test @@ -129,7 +129,7 @@ class LocaleConfigurationTest extends DrupalWebTestCase { $this->drupalGet('admin/config/regional/language'); $this->clickLink(t('delete')); $this->assertText(t('Are you sure you want to delete the language'), t('"delete" link is correct.')); - // Delete the language. + // Delete an enabled language. $this->drupalGet('admin/config/regional/language/delete/' . $langcode); // First test the 'cancel' link. $this->clickLink(t('Cancel')); @@ -144,6 +144,31 @@ class LocaleConfigurationTest extends DrupalWebTestCase { // Verify that language is no longer found. $this->drupalGet('admin/config/regional/language/delete/' . $langcode); $this->assertResponse(404, t('Language no longer found.')); + // Make sure the "language_count" variable has been updated correctly. + drupal_static_reset('language_list'); + $enabled = language_list('enabled'); + $this->assertEqual(variable_get('language_count', 1), count($enabled[1]), t('Language count is correct.')); + // Delete a disabled language. + // Disable an enabled language. + $edit = array( + 'enabled[fr]' => FALSE, + ); + $this->drupalPost($path, $edit, t('Save configuration')); + $this->assertNoFieldChecked('edit-enabled-fr', t('French language disabled.')); + // Get the count of enabled languages. + drupal_static_reset('language_list'); + $enabled = language_list('enabled'); + // Delete the disabled language. + $this->drupalPost('admin/config/regional/language/delete/fr', array(), t('Delete')); + // We need raw here because %locale will add HTML. + $this->assertRaw(t('The language %locale has been removed.', array('%locale' => 'French')), t('Disabled language has been removed.')); + $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.')); + // Verify that language is no longer found. + $this->drupalGet('admin/config/regional/language/delete/fr'); + $this->assertResponse(404, t('Language no longer found.')); + // Make sure the "language_count" variable has not changed. + $this->assertEqual(variable_get('language_count', 1), count($enabled[1]), t('Language count is correct.')); + // Ensure we can't delete the English language. $this->drupalGet('admin/config/regional/language/delete/en'); |