Commit 47055769 authored by webchick's avatar webchick

Issue #1637710 by Schnitzel, vasi1186: Fixed Pass on language weight to...

Issue #1637710 by Schnitzel, vasi1186: Fixed Pass on language weight to language_locked_languages() when available.
parent f772c109
...@@ -2691,9 +2691,9 @@ function language_list($all = FALSE) { ...@@ -2691,9 +2691,9 @@ function language_list($all = FALSE) {
else { else {
// No language module, so use the default language only. // No language module, so use the default language only.
$languages = array($default->langcode => $default); $languages = array($default->langcode => $default);
}
// Add the special languages, they will be filtered later if needed. // Add the special languages, they will be filtered later if needed.
$languages += language_locked_languages(); $languages += language_locked_languages($default->weight);
}
} }
// Filter the full list of languages based on the value of the $all flag. By // Filter the full list of languages based on the value of the $all flag. By
...@@ -2720,7 +2720,7 @@ function language_list($all = FALSE) { ...@@ -2720,7 +2720,7 @@ function language_list($all = FALSE) {
* @return * @return
* An array of language objects. * An array of language objects.
*/ */
function language_locked_languages($weight = 20) { function language_locked_languages($weight = 0) {
$locked_language = array( $locked_language = array(
'default' => FALSE, 'default' => FALSE,
'locked' => TRUE, 'locked' => TRUE,
...@@ -2731,17 +2731,17 @@ function language_locked_languages($weight = 20) { ...@@ -2731,17 +2731,17 @@ function language_locked_languages($weight = 20) {
$languages[LANGUAGE_NOT_SPECIFIED] = new Language(array( $languages[LANGUAGE_NOT_SPECIFIED] = new Language(array(
'langcode' => LANGUAGE_NOT_SPECIFIED, 'langcode' => LANGUAGE_NOT_SPECIFIED,
'name' => t('Not specified'), 'name' => t('Not specified'),
'weight' => $weight++, 'weight' => ++$weight,
) + $locked_language); ) + $locked_language);
$languages[LANGUAGE_NOT_APPLICABLE] = new Language(array( $languages[LANGUAGE_NOT_APPLICABLE] = new Language(array(
'langcode' => LANGUAGE_NOT_APPLICABLE, 'langcode' => LANGUAGE_NOT_APPLICABLE,
'name' => t('Not applicable'), 'name' => t('Not applicable'),
'weight' => $weight++, 'weight' => ++$weight,
) + $locked_language); ) + $locked_language);
$languages[LANGUAGE_MULTIPLE] = new Language(array( $languages[LANGUAGE_MULTIPLE] = new Language(array(
'langcode' => LANGUAGE_MULTIPLE, 'langcode' => LANGUAGE_MULTIPLE,
'name' => t('Multiple'), 'name' => t('Multiple'),
'weight' => $weight++, 'weight' => ++$weight,
) + $locked_language); ) + $locked_language);
return $languages; return $languages;
} }
......
...@@ -234,7 +234,8 @@ function update_prepare_d8_language() { ...@@ -234,7 +234,8 @@ function update_prepare_d8_language() {
); );
db_add_field('language', 'locked', $locked_spec); db_add_field('language', 'locked', $locked_spec);
$languages = language_locked_languages(); $max_language_weight = db_query('SELECT MAX(weight) FROM {language}')->fetchField();
$languages = language_locked_languages($max_language_weight);
foreach ($languages as $language) { foreach ($languages as $language) {
db_insert('language') db_insert('language')
->fields(array( ->fields(array(
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
function language_install() { function language_install() {
// Add the default language at first so that language_list() returns this in // Add the default language at first so that language_list() returns this in
// language_special_languages(). // language_special_languages().
language_save(language_default()); $default_language = language_save(language_default());
$languages = language_locked_languages(); $languages = language_locked_languages($default_language->weight);
foreach ($languages as $language) { foreach ($languages as $language) {
language_save($language); language_save($language);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment