summaryrefslogtreecommitdiff
path: root/includes/path.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-06-24 22:12:15 +0000
committerDries Buytaert <dries@buytaert.net>2008-06-24 22:12:15 +0000
commit955ef193ba5d71450bd129e74d34459318b76a8b (patch)
tree36e23b792209ea7f072e7871cba2612bf1d97237 /includes/path.inc
parent6aea1d08736936a7181ee5bcdfe384c802ce5e0a (diff)
downloadbrdo-955ef193ba5d71450bd129e74d34459318b76a8b.tar.gz
brdo-955ef193ba5d71450bd129e74d34459318b76a8b.tar.bz2
- Patch #196862 by catch: rolled back path optimization as it broke certain tests.
Diffstat (limited to 'includes/path.inc')
-rw-r--r--includes/path.inc9
1 files changed, 7 insertions, 2 deletions
diff --git a/includes/path.inc b/includes/path.inc
index fd1e3448d..617e69a23 100644
--- a/includes/path.inc
+++ b/includes/path.inc
@@ -46,15 +46,20 @@ function drupal_init_path() {
function drupal_lookup_path($action, $path = '', $path_language = '') {
global $language;
// $map is an array with language keys, holding arrays of Drupal paths to alias relations
- static $map = array(), $no_src = array();
+ static $map = array(), $no_src = array(), $count;
$path_language = $path_language ? $path_language : $language->language;
+ // Use $count to avoid looking up paths in subsequent calls if there simply are no aliases
+ if (!isset($count)) {
+ $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
+ }
+
if ($action == 'wipe') {
$map = array();
$no_src = array();
}
- elseif (module_exists('path') && $path != '') {
+ elseif ($count > 0 && $path != '') {
if ($action == 'alias') {
if (isset($map[$path_language][$path])) {
return $map[$path_language][$path];