- Patch #100957 by chx: clean up drupal_lookup_path()

5.x
Dries Buytaert 2006-12-23 22:04:52 +00:00
parent 0d57baef27
commit 5c3086ee4a
1 changed files with 3 additions and 5 deletions

View File

@ -42,10 +42,10 @@ function drupal_init_path() {
function drupal_lookup_path($action, $path = '') {
// $map keys are Drupal paths and the values are the corresponding aliases
static $map = array(), $no_src = array();
static $count = NULL;
static $count;
// Use $count to avoid looking up paths in subsequent calls if there simply are no aliases
if ($count === NULL) {
if (!isset($count)) {
$count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
}
@ -58,9 +58,7 @@ function drupal_lookup_path($action, $path = '') {
if (isset($map[$path])) {
return $map[$path];
}
if (!$alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path))) {
$alias = FALSE;
}
$alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path));
$map[$path] = $alias;
return $alias;
}