Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.7
diff -u -F^f -r1.7 path.inc
--- includes/path.inc	23 Aug 2006 04:31:30 -0000	1.7
+++ includes/path.inc	9 Sep 2006 11:12:15 -0000
@@ -51,26 +51,33 @@ function drupal_lookup_path($action, $pa
   }
   elseif ($count > 0 && $path != '') {
     if ($action == 'alias') {
+      // look for a cached match
       if (isset($map[$path])) {
         return $map[$path];
       }
+      // if no cached match, look in the database
       if ($alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path))) {
         $map[$path] = $alias;
         return $alias;
       }
+      // if neither of the above sources provided a match, cache the path as the path
       else {
         $map[$path] = $path;
       }
     }
     elseif ($action == 'source') {
+      // look for a cached match
       if ($alias = array_search($path, $map)) {
         return $alias;
       }
-      if (!isset($map[$path])) {
-        if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
-          $map[$src] = $path;
-          return $src;
-        }
+      // if no cached match, look in the database
+      if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
+        $map[$src] = $path;
+        return $src;
+      }
+      // if neither of the above sources provided a match, cache the path as the path
+      else {
+        $map[$path] = $path;
       }
     }
   }
