Convert language_negotiation_* variables to use the new callbacks.
function locale_update_8007() {
$variable_names = array(
'language_negotiation_language_interface',
'language_negotiation_language_content',
'language_negotiation_language_url',
);
// Add all language type weight variables. As the function language_types()
// is not available its functionality is rebuild.
$language_types = update_variable_get('language_types', array(
Language::TYPE_INTERFACE => TRUE,
Language::TYPE_CONTENT => FALSE,
Language::TYPE_URL => FALSE,
));
foreach ($language_types as $language_type => $configurable) {
$variable_names[] = 'language_negotiation_methods_weight_' . $language_type;
}
$callback_map = array(
'locale_language_from_url' => 'language_from_url',
'locale_language_switcher_url' => 'language_switcher_url',
'locale_language_url_rewrite_url' => 'language_url_rewrite_url',
'locale_language_from_session' => 'language_from_session',
'locale_language_switcher_session' => 'language_switcher_session',
'locale_language_url_rewrite_session' => 'language_url_rewrite_session',
'locale_language_from_user' => 'language_from_user',
'locale_language_from_browser' => 'language_from_browser',
'locale_language_url_fallback' => 'language_url_fallback',
'locale_language_from_interface' => 'language_from_interface',
);
$type_map = array(
'locale-interface' => 'language-interface',
'locale-url' => 'language-url',
'locale-url-fallback' => 'language-url-fallback',
'locale-browser' => 'language-browser',
'locale-user' => 'language-user',
'locale-session' => 'language-session',
);
foreach ($variable_names as $variable_name) {
$value = update_variable_get($variable_name);
// Skip processing if the variable is not stored in the db.
if ($value === NULL) {
continue;
}
$new_value = $value;
foreach ($value as $type => $type_settings) {
// Convert the file.
if (isset($type_settings['file']) && strpos($type_settings['file'], 'core/includes/locale.inc') !== FALSE) {
$new_value[$type]['file'] = 'core/modules/language/language.negotiation.inc';
}
// Convert the callbacks.
if (is_array($type_settings) && isset($type_settings['callbacks'])) {
foreach ($type_settings['callbacks'] as $key => $callback) {
if (isset($callback_map[$callback])) {
$new_value[$type]['callbacks'][$key] = $callback_map[$callback];
}
}
}
// Convert the type.
if (isset($type_map[$type])) {
$new_value[$type_map[$type]] = $new_value[$type];
unset($new_value[$type]);
}
}
// If necessary maintain the order of the values / keys of the variable.
if (stristr($variable_name, 'language_negotiation_methods_weight_') !== FALSE) {
asort($new_value);
}
update_variable_set($variable_name, $new_value);
}
}