Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#27196] Unable to add a trashed Content Language again #18

Closed
wants to merge 13 commits into from
Prev Previous commit
Next Next commit
Make sure the Language Code is unique
  • Loading branch information
Michael Babker committed Nov 19, 2011
commit d5973b8e059e1486abc8069c52f2ce633a17b34b
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ALTER TABLE `#__languages` ADD UNIQUE `idx_image` (`image`);
ALTER TABLE `#__languages` ADD UNIQUE `idx_image` (`image`);
ALTER TABLE `#__languages` ADD UNIQUE `idx_langcode` (`lang_code`);
1 change: 1 addition & 0 deletions administrator/language/en-GB/en-GB.lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ JLIB_DATABASE_ERROR_INVALID_NODE_RECURSION="%s: :move Failed - Cannot move the n
JLIB_DATABASE_ERROR_INVALID_PARENT_ID="Invalid parent id."
JLIB_DATABASE_ERROR_LANGUAGE_NO_TITLE="The language should have a title"
JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_IMAGE="A content language already exists with this Image Prefix"
JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_LANG_CODE="A content language already exists with this Language Code"
JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_SEF="A content language already exists with this Language Tag"
JLIB_DATABASE_ERROR_LOAD_DATABASE_DRIVER="Unable to load Database Driver: %s"
JLIB_DATABASE_ERROR_MENUTYPE_EMPTY="Menu type empty"
Expand Down
1 change: 1 addition & 0 deletions installation/sql/mysql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ CREATE TABLE `#__languages` (
PRIMARY KEY (`lang_id`),
UNIQUE `idx_sef` (`sef`),
UNIQUE `idx_image` (`image`),
UNIQUE `idx_langcode` (`lang_code`),
INDEX `idx_ordering` (`ordering`)
) DEFAULT CHARSET=utf8;

Expand Down
1 change: 1 addition & 0 deletions language/en-GB/en-GB.lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ JLIB_DATABASE_ERROR_INVALID_NODE_RECURSION="%s: :move Failed - Cannot move the n
JLIB_DATABASE_ERROR_INVALID_PARENT_ID="Invalid parent id."
JLIB_DATABASE_ERROR_LANGUAGE_NO_TITLE="The language should have a title"
JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_IMAGE="A content language already exists with this Image Prefix"
JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_LANG_CODE="A content language already exists with this Language Code"
JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_SEF="A content language already exists with this Language Tag"
JLIB_DATABASE_ERROR_LOAD_DATABASE_DRIVER="Unable to load Database Driver: %s"
JLIB_DATABASE_ERROR_MENUTYPE_EMPTY="Menu type empty"
Expand Down
7 changes: 7 additions & 0 deletions libraries/joomla/database/table/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public function store($updateNulls = false)
$this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_IMAGE'));
return false;
}

// Verify that the language code is unique
if ($table->load(array('lang_code' => $this->lang_code)) && ($table->lang_id != $this->lang_id || $this->lang_id == 0))
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_LANG_CODE'));
return false;
}
return parent::store($updateNulls);
}
}