Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.651
diff -u -F^f -r1.651 common.inc
--- includes/common.inc	4 Jun 2007 07:22:16 -0000	1.651
+++ includes/common.inc	7 Jun 2007 18:12:47 -0000
@@ -1232,6 +1232,10 @@ function url($path = NULL, $options = ar
     if (!$options['alias']) {
       $path = drupal_get_path_alias($path);
     }
+    if (function_exists('custom_url_rewrite_outbound')) {
+      // Modules may alter outbound links.
+      list($path, $options) = custom_url_rewrite_outbound($path, $options);
+    }
     $path = drupal_urlencode($path);
     if (!$clean_url) {
       if ($options['query']) {
Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.15
diff -u -F^f -r1.15 path.inc
--- includes/path.inc	26 Mar 2007 01:32:22 -0000	1.15
+++ includes/path.inc	7 Jun 2007 18:12:51 -0000
@@ -110,9 +110,6 @@ function drupal_get_path_alias($path, $p
   if ($alias = drupal_lookup_path('alias', $path, $path_language)) {
     $result = $alias;
   }
-  if (function_exists('custom_url_rewrite')) {
-    $result = custom_url_rewrite('alias', $result, $path, $path_language);
-  }
   return $result;
 }
 
@@ -133,8 +130,9 @@ function drupal_get_normal_path($path, $
   if ($src = drupal_lookup_path('source', $path, $path_language)) {
     $result = $src;
   }
-  if (function_exists('custom_url_rewrite')) {
-    $result = custom_url_rewrite('source', $result, $path, $path_language);
+  if (function_exists('custom_url_rewrite_inbound')) {
+    // Modules may alter the inbound request path.
+    $result = custom_url_rewrite_inbound($result, $path, $path_language);
   }
   return $result;
 }
Index: modules/path/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.module,v
retrieving revision 1.121
diff -u -F^f -r1.121 path.module
--- modules/path/path.module	4 Jun 2007 07:22:20 -0000	1.121
+++ modules/path/path.module	7 Jun 2007 18:13:03 -0000
@@ -233,11 +233,10 @@ function path_nodeapi(&$node, $op, $arg)
 
       case 'load':
         $path = "node/$node->nid";
-        // We don't use drupal_get_path_alias() to avoid custom rewrite functions.
-        // We only care about exact aliases.
-        $result = db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path);
-        if (db_num_rows($result)) {
-          $node->path = db_result($result);
+        $language = isset($node->language) ? $node->language : '';
+        $alias = drupal_get_path_alias($path, $language);
+        if ($path != $alias) {
+          $node->path = $alias;
         }
         break;
 
