Hello, i believe there is mistake in drupal_lookup_path() function, because if i have 2 aliases for the same node in different languages - in my lang and in LANGUAGE_NONE, then this function will first time after cache clear return an alias for my lang, but after that it will always return an alias of LANGUAGE_NONE.
You can reproduse this, by creating 2 aliases for same node - first in language 'en', second in language LANGUAGE_NONE. You need to clear cache, and then call drupal_lookup_path('alias', 'node/[your_node_id]', 'en'). This function will return to you alias in language 'en'. Refresh the page, and you will see, that the alias changed to LANGUAGE_NONE.
i'm sure this strange behaviour is because different logic used in drupal_lookup_path for first time, and later, when getting alias from cache. As you can see below, the ordering is totally reversed for some strange reason.
path.inc from line 108:
<?php
if ($path_language == 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);
}
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);
}
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);
}
?>
but couple lines below the ordering is reversed
path.inc from line 142:
<?php
// 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();
}
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();
}
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();
}
?>