Commit 1b6ba524 authored by Dries's avatar Dries
Browse files

- Patch #1357912 by Gábor Hojtsy, sun: convert path language code schema to langcode.

parent 7ef099f5
......@@ -33,7 +33,7 @@ function drupal_path_initialize() {
* - source: return the Drupal system URL for a path alias (if one exists).
* @param $path
* The path to investigate for corresponding aliases or system URLs.
* @param $path_language
* @param $langcode
* Optional language code to search the path with. Defaults to the page language.
* If there's no path defined for that language it will search paths without
* language.
......@@ -42,7 +42,7 @@ function drupal_path_initialize() {
* Either a Drupal system path, an aliased path, or FALSE if no path was
* found.
*/
function drupal_lookup_path($action, $path = '', $path_language = NULL) {
function drupal_lookup_path($action, $path = '', $langcode = NULL) {
global $language_url;
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
......@@ -74,7 +74,7 @@ function drupal_lookup_path($action, $path = '', $path_language = NULL) {
// language. If we used a language different from the one conveyed by the
// requested URL, we might end up being unable to check if there is a path
// alias matching the URL path.
$path_language = $path_language ? $path_language : $language_url->langcode;
$langcode = $langcode ? $langcode : $language_url->langcode;
if ($action == 'wipe') {
$cache = array();
......@@ -87,7 +87,7 @@ function drupal_lookup_path($action, $path = '', $path_language = NULL) {
if (!empty($cache['first_call'])) {
$cache['first_call'] = FALSE;
$cache['map'][$path_language] = array();
$cache['map'][$langcode] = array();
// Load system paths from cache.
$cid = current_path();
if ($cached = cache('path')->get($cid)) {
......@@ -95,7 +95,7 @@ function drupal_lookup_path($action, $path = '', $path_language = NULL) {
// Now fetch the aliases corresponding to these system paths.
$args = array(
':system' => $cache['system_paths'],
':language' => $path_language,
':langcode' => $langcode,
':language_none' => LANGUAGE_NONE,
);
// Always get the language-specific alias before the language-neutral
......@@ -105,25 +105,25 @@ function drupal_lookup_path($action, $path = '', $path_language = NULL) {
// the most recently created alias for each source. Subsequent queries
// using fetchField() must use pid DESC to have the same effect.
// For performance reasons, the query builder is not used here.
if ($path_language == LANGUAGE_NONE) {
if ($langcode == LANGUAGE_NONE) {
// Prevent PDO from complaining about a token the query doesn't use.
unset($args[':language']);
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language = :language_none ORDER BY pid ASC', $args);
unset($args[':langcode']);
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode = :language_none ORDER BY pid ASC', $args);
}
elseif ($path_language < LANGUAGE_NONE) {
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, :language_none) ORDER BY language ASC, pid ASC', $args);
elseif ($langcode < LANGUAGE_NONE) {
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode IN (:langcode, :language_none) ORDER BY langcode ASC, pid ASC', $args);
}
else {
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND language IN (:language, :language_none) ORDER BY language DESC, pid ASC', $args);
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode IN (:langcode, :language_none) ORDER BY langcode DESC, pid ASC', $args);
}
$cache['map'][$path_language] = $result->fetchAllKeyed();
$cache['map'][$langcode] = $result->fetchAllKeyed();
// Keep a record of paths with no alias to avoid querying twice.
$cache['no_aliases'][$path_language] = array_flip(array_diff_key($cache['system_paths'], array_keys($cache['map'][$path_language])));
$cache['no_aliases'][$langcode] = array_flip(array_diff_key($cache['system_paths'], array_keys($cache['map'][$langcode])));
}
}
// If the alias has already been loaded, return it.
if (isset($cache['map'][$path_language][$path])) {
return $cache['map'][$path_language][$path];
if (isset($cache['map'][$langcode][$path])) {
return $cache['map'][$langcode][$path];
}
// Check the path whitelist, if the top_level part before the first /
// is not in the list, then there is no need to do anything further,
......@@ -132,57 +132,57 @@ function drupal_lookup_path($action, $path = '', $path_language = NULL) {
return FALSE;
}
// For system paths which were not cached, query aliases individually.
elseif (!isset($cache['no_aliases'][$path_language][$path])) {
elseif (!isset($cache['no_aliases'][$langcode][$path])) {
$args = array(
':source' => $path,
':language' => $path_language,
':langcode' => $langcode,
':language_none' => LANGUAGE_NONE,
);
// See the queries above.
if ($path_language == LANGUAGE_NONE) {
unset($args[':language']);
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language = :language_none ORDER BY pid DESC", $args)->fetchField();
if ($langcode == LANGUAGE_NONE) {
unset($args[':langcode']);
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode = :language_none ORDER BY pid DESC", $args)->fetchField();
}
elseif ($path_language > LANGUAGE_NONE) {
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", $args)->fetchField();
elseif ($langcode > LANGUAGE_NONE) {
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode IN (:langcode, :language_none) ORDER BY langcode DESC, pid DESC", $args)->fetchField();
}
else {
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND language IN (:language, :language_none) ORDER BY language ASC, pid DESC", $args)->fetchField();
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode IN (:langcode, :language_none) ORDER BY langcode ASC, pid DESC", $args)->fetchField();
}
$cache['map'][$path_language][$path] = $alias;
$cache['map'][$langcode][$path] = $alias;
return $alias;
}
}
// Check $no_source for this $path in case we've already determined that there
// isn't a path that has this alias
elseif ($action == 'source' && !isset($cache['no_source'][$path_language][$path])) {
elseif ($action == 'source' && !isset($cache['no_source'][$langcode][$path])) {
// Look for the value $path within the cached $map
$source = FALSE;
if (!isset($cache['map'][$path_language]) || !($source = array_search($path, $cache['map'][$path_language]))) {
if (!isset($cache['map'][$langcode]) || !($source = array_search($path, $cache['map'][$langcode]))) {
$args = array(
':alias' => $path,
':language' => $path_language,
':langcode' => $langcode,
':language_none' => LANGUAGE_NONE,
);
// See the queries above.
if ($path_language == LANGUAGE_NONE) {
unset($args[':language']);
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language = :language_none ORDER BY pid DESC", $args);
if ($langcode == LANGUAGE_NONE) {
unset($args[':langcode']);
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode = :language_none ORDER BY pid DESC", $args);
}
elseif ($path_language > LANGUAGE_NONE) {
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", $args);
elseif ($langcode > LANGUAGE_NONE) {
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :language_none) ORDER BY langcode DESC, pid DESC", $args);
}
else {
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language ASC, pid DESC", $args);
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :language_none) ORDER BY langcode ASC, pid DESC", $args);
}
if ($source = $result->fetchField()) {
$cache['map'][$path_language][$source] = $path;
$cache['map'][$langcode][$source] = $path;
}
else {
// We can't record anything into $map because we do not have a valid
// index and there is no need because we have not learned anything
// about any Drupal path. Thus cache to $no_source.
$cache['no_source'][$path_language][$path] = TRUE;
$cache['no_source'][$langcode][$path] = TRUE;
}
}
return $source;
......@@ -225,20 +225,20 @@ function drupal_cache_system_paths() {
*
* @param $path
* An internal Drupal path.
* @param $path_language
* @param $langcode
* An optional language code to look up the path in.
*
* @return
* An aliased path if one was found, or the original path if no alias was
* found.
*/
function drupal_get_path_alias($path = NULL, $path_language = NULL) {
function drupal_get_path_alias($path = NULL, $langcode = NULL) {
// If no path is specified, use the current page's path.
if ($path == NULL) {
$path = $_GET['q'];
}
$result = $path;
if ($alias = drupal_lookup_path('alias', $path, $path_language)) {
if ($alias = drupal_lookup_path('alias', $path, $langcode)) {
$result = $alias;
}
return $result;
......@@ -249,18 +249,18 @@ function drupal_get_path_alias($path = NULL, $path_language = NULL) {
*
* @param $path
* A Drupal path alias.
* @param $path_language
* @param $langcode
* An optional language code to look up the path in.
*
* @return
* The internal path represented by the alias, or the original alias if no
* internal path was found.
*/
function drupal_get_normal_path($path, $path_language = NULL) {
function drupal_get_normal_path($path, $langcode = NULL) {
$original_path = $path;
// Lookup the path alias first.
if ($source = drupal_lookup_path('source', $path, $path_language)) {
if ($source = drupal_lookup_path('source', $path, $langcode)) {
$path = $source;
}
......@@ -269,7 +269,7 @@ function drupal_get_normal_path($path, $path_language = NULL) {
// of hook_url_outbound_alter().
foreach (array_reverse(module_implements('url_inbound_alter')) as $module) {
$function = $module . '_url_inbound_alter';
$function($path, $original_path, $path_language);
$function($path, $original_path, $langcode);
}
return $path;
......@@ -398,7 +398,7 @@ function drupal_path_alias_whitelist_rebuild($source = NULL) {
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - language: The language of the alias.
* - langcode: The language code of the alias.
*/
function path_load($conditions) {
if (is_numeric($conditions)) {
......@@ -428,10 +428,10 @@ function path_load($conditions) {
* - source: The internal system path.
* - alias: The URL alias.
* - pid: (optional) Unique path alias identifier.
* - language: (optional) The language of the alias.
* - langcode: (optional) The language code of the alias.
*/
function path_save(&$path) {
$path += array('pid' => NULL, 'language' => LANGUAGE_NONE);
$path += array('pid' => NULL, 'langcode' => LANGUAGE_NONE);
// Insert or update the alias.
$status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : array()));
......
......@@ -103,6 +103,26 @@ function update_prepare_d8_bootstrap() {
if ($has_required_schema) {
// Update the environment for the language bootstrap if needed.
update_prepare_d8_language();
// Change language column to langcode in url_alias.
if (db_table_exists('url_alias') && db_field_exists('url_alias', 'language')) {
db_drop_index('url_alias', 'alias_language_pid');
db_drop_index('url_alias', 'source_language_pid');
$langcode_spec = array(
'description' => "The language code this alias is for; if 'und', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.",
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
);
$langcode_indexes = array('indexes' =>
array(
'alias_langcode_pid' => array('alias', 'langcode', 'pid'),
'source_langcode_pid' => array('source', 'langcode', 'pid'),
),
);
db_change_field('url_alias', 'language', 'langcode', $langcode_spec, $langcode_indexes);
}
}
}
}
......
......@@ -1654,7 +1654,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
$edit = array(
'source' => 'node/' . $node->nid,
'alias' => $english_path,
'language' => 'en',
'langcode' => 'en',
);
$this->drupalPost($path, $edit, t('Save'));
......@@ -1663,7 +1663,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
$edit = array(
'source' => 'node/' . $node->nid,
'alias' => $custom_language_path,
'language' => $langcode,
'langcode' => $langcode,
);
$this->drupalPost($path, $edit, t('Save'));
......@@ -1682,7 +1682,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
$edit = array(
'source' => 'node/' . $node->nid,
'alias' => $custom_path,
'language' => LANGUAGE_NONE,
'langcode' => LANGUAGE_NONE,
);
path_save($edit);
$lookup_path = drupal_lookup_path('alias', 'node/' . $node->nid, 'en');
......@@ -1700,7 +1700,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
$edit = array(
'source' => 'node/' . $first_node->nid,
'alias' => $custom_path,
'language' => 'en',
'langcode' => 'en',
);
path_save($edit);
......@@ -1708,7 +1708,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
$edit = array(
'source' => 'node/' . $second_node->nid,
'alias' => $custom_path,
'language' => LANGUAGE_NONE,
'langcode' => LANGUAGE_NONE,
);
path_save($edit);
......
......@@ -15,14 +15,14 @@ function path_admin_overview($keys = NULL) {
// Add the filter form above the overview table.
$build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys);
// Enable language column if locale is enabled or if we have any alias with language
$alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE language <> :language', 0, 1, array(':language' => LANGUAGE_NONE))->fetchField();
$alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => LANGUAGE_NONE))->fetchField();
$multilanguage = (module_exists('locale') || $alias_exists);
$header = array();
$header[] = array('data' => t('Alias'), 'field' => 'alias', 'sort' => 'asc');
$header[] = array('data' => t('System'), 'field' => 'source');
if ($multilanguage) {
$header[] = array('data' => t('Language'), 'field' => 'language');
$header[] = array('data' => t('Language'), 'field' => 'langcode');
}
$header[] = array('data' => t('Operations'));
......@@ -44,7 +44,7 @@ function path_admin_overview($keys = NULL) {
$row['data']['alias'] = l($data->alias, $data->source);
$row['data']['source'] = l($data->source, $data->source, array('alias' => TRUE));
if ($multilanguage) {
$row['data']['language'] = module_invoke('locale', 'language_name', $data->language);
$row['data']['langcode'] = module_invoke('locale', 'language_name', $data->langcode);
}
$operations = array();
......@@ -68,7 +68,7 @@ function path_admin_overview($keys = NULL) {
// If the system path maps to a different URL alias, highlight this table
// row to let the user know of old aliases.
if ($data->alias != drupal_get_path_alias($data->source, $data->language)) {
if ($data->alias != drupal_get_path_alias($data->source, $data->langcode)) {
$row['class'] = array('warning');
}
......@@ -108,7 +108,7 @@ function path_admin_edit($path = array()) {
* @see path_admin_form_validate()
* @see path_admin_form_submit()
*/
function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'language' => LANGUAGE_NONE, 'pid' => NULL)) {
function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'langcode' => LANGUAGE_NONE, 'pid' => NULL)) {
$form['source'] = array(
'#type' => 'textfield',
'#title' => t('Existing system path'),
......@@ -132,19 +132,19 @@ function path_admin_form($form, &$form_state, $path = array('source' => '', 'ali
// A hidden value unless locale module is enabled.
if (module_exists('locale')) {
$form['language'] = array(
$form['langcode'] = array(
'#type' => 'select',
'#title' => t('Language'),
'#options' => array(LANGUAGE_NONE => t('All languages')) + locale_language_list('name'),
'#default_value' => $path['language'],
'#default_value' => $path['langcode'],
'#weight' => -10,
'#description' => t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set for <em>All languages</em>.'),
);
}
else {
$form['language'] = array(
$form['langcode'] = array(
'#type' => 'value',
'#value' => $path['language']
'#value' => $path['langcode']
);
}
......@@ -189,12 +189,12 @@ function path_admin_form_validate($form, &$form_state) {
$alias = $form_state['values']['alias'];
$pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
// Language is only set if locale module is enabled, otherwise save for all languages.
$language = isset($form_state['values']['language']) ? $form_state['values']['language'] : LANGUAGE_NONE;
$langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : LANGUAGE_NONE;
$has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND language = :language", array(
$has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND langcode = :langcode", array(
':pid' => $pid,
':alias' => $alias,
':language' => $language,
':langcode' => $langcode,
))
->fetchField();
......
......@@ -19,7 +19,7 @@
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - language: The language of the alias.
* - langcode: The language code of the alias.
*
* @see path_save()
*/
......@@ -40,7 +40,7 @@ function hook_path_insert($path) {
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - language: The language of the alias.
* - langcode: The language code of the alias.
*
* @see path_save()
*/
......@@ -59,7 +59,7 @@ function hook_path_update($path) {
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - language: The language of the alias.
* - langcode: The language code of the alias.
*
* @see path_delete()
*/
......
......@@ -98,7 +98,7 @@ function path_form_node_form_alter(&$form, $form_state) {
if (!empty($form['#node']->nid)) {
$conditions = array('source' => 'node/' . $form['#node']->nid);
if ($form['#node']->language != LANGUAGE_NONE) {
$conditions['language'] = $form['#node']->language;
$conditions['langcode'] = $form['#node']->language;
}
$path = path_load($conditions);
if ($path === FALSE) {
......@@ -109,7 +109,7 @@ function path_form_node_form_alter(&$form, $form_state) {
'pid' => NULL,
'source' => isset($form['#node']->nid) ? 'node/' . $form['#node']->nid : NULL,
'alias' => '',
'language' => isset($form['#node']->language) ? $form['#node']->language : LANGUAGE_NONE,
'langcode' => isset($form['#node']->language) ? $form['#node']->language : LANGUAGE_NONE,
);
$form['path'] = array(
......@@ -140,7 +140,7 @@ function path_form_node_form_alter(&$form, $form_state) {
);
$form['path']['pid'] = array('#type' => 'value', '#value' => $path['pid']);
$form['path']['source'] = array('#type' => 'value', '#value' => $path['source']);
$form['path']['language'] = array('#type' => 'value', '#value' => $path['language']);
$form['path']['langcode'] = array('#type' => 'value', '#value' => $path['langcode']);
}
/**
......@@ -151,14 +151,14 @@ function path_form_element_validate($element, &$form_state, $complete_form) {
// Trim the submitted value.
$alias = trim($form_state['values']['path']['alias']);
form_set_value($element['alias'], $alias, $form_state);
// Node language (Locale module) needs special care. Since the language of
// the URL alias depends on the node language, and the node language can be
// switched right within the same form, we need to conditionally overload
// the originally assigned URL alias language.
// Node language needs special care. Since the language of the URL alias
// depends on the node language, and the node language can be switched
// right within the same form, we need to conditionally overload the
// originally assigned URL alias language.
// @todo Remove this after converting Path module to a field, and, after
// stopping Locale module from abusing the content language system.
if (isset($form_state['values']['language'])) {
form_set_value($element['language'], $form_state['values']['language'], $form_state);
form_set_value($element['langcode'], $form_state['values']['language'], $form_state);
}
$path = $form_state['values']['path'];
......@@ -166,7 +166,7 @@ function path_form_element_validate($element, &$form_state, $complete_form) {
// Ensure that the submitted alias does not exist yet.
$query = db_select('url_alias')
->condition('alias', $path['alias'])
->condition('language', $path['language']);
->condition('langcode', $path['langcode']);
if (!empty($path['source'])) {
$query->condition('source', $path['source'], '<>');
}
......@@ -189,7 +189,7 @@ function path_node_insert($node) {
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$path['source'] = 'node/' . $node->nid;
$path['language'] = isset($node->language) ? $node->language : LANGUAGE_NONE;
$path['langcode'] = isset($node->language) ? $node->language : LANGUAGE_NONE;
path_save($path);
}
}
......@@ -210,7 +210,7 @@ function path_node_update($node) {
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$path['source'] = 'node/' . $node->nid;
$path['language'] = isset($node->language) ? $node->language : LANGUAGE_NONE;
$path['langcode'] = isset($node->language) ? $node->language : LANGUAGE_NONE;
path_save($path);
}
}
......@@ -238,7 +238,7 @@ function path_form_taxonomy_form_term_alter(&$form, $form_state) {
'pid' => NULL,
'source' => isset($form['#term']['tid']) ? 'taxonomy/term/' . $form['#term']['tid'] : NULL,
'alias' => '',
'language' => LANGUAGE_NONE,
'langcode' => LANGUAGE_NONE,
);
$form['path'] = array(
'#access' => user_access('create url aliases') || user_access('administer url aliases'),
......@@ -255,7 +255,7 @@ function path_form_taxonomy_form_term_alter(&$form, $form_state) {
);
$form['path']['pid'] = array('#type' => 'value', '#value' => $path['pid']);
$form['path']['source'] = array('#type' => 'value', '#value' => $path['source']);
$form['path']['language'] = array('#type' => 'value', '#value' => $path['language']);
$form['path']['langcode'] = array('#type' => 'value', '#value' => $path['langcode']);
}
}
......@@ -270,7 +270,7 @@ function path_taxonomy_term_insert($term) {
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$path['source'] = 'taxonomy/term/' . $term->tid;
$path['language'] = LANGUAGE_NONE;
$path['langcode'] = LANGUAGE_NONE;
path_save($path);
}
}
......@@ -291,7 +291,7 @@ function path_taxonomy_term_update($term) {
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$path['source'] = 'taxonomy/term/' . $term->tid;
$path['language'] = LANGUAGE_NONE;
$path['langcode'] = LANGUAGE_NONE;
path_save($path);
}
}
......
......@@ -420,7 +420,7 @@ class PathLanguageUITestCase extends DrupalWebTestCase {
$edit = array();
$edit['source'] = 'admin/config/search/path';
$edit['alias'] = $name;
$edit['language'] = 'en';
$edit['langcode'] = 'en';
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
$this->drupalGet($name);
......@@ -435,7 +435,7 @@ class PathLanguageUITestCase extends DrupalWebTestCase {
$edit = array();
$edit['source'] = 'admin/config/search/path';
$edit['alias'] = $name;
$edit['language'] = 'fr';
$edit['langcode'] = 'fr';
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
$this->drupalGet('fr/' . $name);
......
......@@ -278,7 +278,7 @@ class PathLookupTest extends DrupalWebTestCase {
$path = array(
'source' => "user/$uid",
'alias' => "users/$name",
'language' => 'en',
'langcode' => 'en',
);
path_save($path);
$this->assertEqual(drupal_lookup_path('alias', $path['source']), $path['alias'], t('English alias overrides language-neutral alias.'));
......@@ -296,7 +296,7 @@ class PathLookupTest extends DrupalWebTestCase {
$path = array(
'source' => "user/$uid",
'alias' => 'LOL',
'language' => 'xx-lolspeak',
'langcode' => 'xx-lolspeak',
);
path_save($path);
$this->assertEqual(drupal_lookup_path('alias', $path['source']), "users/$name", t('English alias still returned after entering a LOLspeak alias.'));
......@@ -308,7 +308,7 @@ class PathLookupTest extends DrupalWebTestCase {
$path = array(
'source' => "user/$uid",
'alias' => 'users/my-new-path',
'language' => 'en',
'langcode' => 'en',
);
path_save($path);
$this->assertEqual(drupal_lookup_path('alias', $path['source']), $path['alias'], t('Recently created English alias returned.'));
......@@ -317,7 +317,7 @@ class PathLookupTest extends DrupalWebTestCase {
// Remove the English aliases, which should cause a fallback to the most
// recently created language-neutral alias, 'bar'.
db_delete('url_alias')
->condition('language', 'en')
->condition('langcode', 'en')
->execute();
drupal_clear_path_cache();
$this->assertEqual(drupal_lookup_path('alias', $path['source']), 'bar', t('Path lookup falls back to recently created language-neutral alias.'));
......
......@@ -1592,8 +1592,8 @@ function system_schema() {
'not null' => TRUE,
'default' => '',
),
'language' => array(
'description' => "The language this alias is for; if 'und', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.",
'langcode' => array(
'description' => "The language code this alias is for; if 'und', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.",
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
......@@ -1602,8 +1602,8 @@ function system_schema() {
),
'primary key' => array('pid'),
'indexes' => array(
'alias_language_pid' => array('alias', 'language', 'pid'),
'source_language_pid' => array('source', 'language', 'pid'),
'alias_langcode_pid' => array('alias', 'langcode', 'pid'),
'source_langcode_pid' => array('source', 'langcode', 'pid'),
),
);
......
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