Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.383
diff -u -p -r1.383 bootstrap.inc
--- includes/bootstrap.inc	1 May 2010 08:12:22 -0000	1.383
+++ includes/bootstrap.inc	4 May 2010 02:02:14 -0000
@@ -1211,7 +1211,7 @@ function drupal_unpack($obj, $field = 'd
  * - !variable: Indicates that the text should be inserted as-is. This is
  *   useful for inserting variables into things like e-mail. Example:
  *   @code
- *     $message[] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => url("user/$account->uid", array('absolute' => TRUE))));
+ *     $message[] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => url("user/$account->uid/edit", array('absolute' => TRUE))));
  *   @endcode
  * - @variable: Indicates that the text should be run through check_plain(), to
  *   escape HTML characters. Use this for any output that is displayed within a
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1159
diff -u -p -r1.1159 common.inc
--- includes/common.inc	1 May 2010 08:12:22 -0000	1.1159
+++ includes/common.inc	4 May 2010 02:02:15 -0000
@@ -6378,7 +6378,7 @@ function entity_extract_ids($entity_type
   $vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL;
   // If no bundle key provided, then we assume a single bundle, named after the
   // entity type.
-  $bundle = $info['entity keys']['bundle'] ? $entity->{$info['entity keys']['bundle']} : $entity_type;
+  $bundle = ($info['entity keys']['bundle'] && isset($entity->{$info['entity keys']['bundle']})) ? $entity->{$info['entity keys']['bundle']} : $entity_type;
   return array($id, $vid, $bundle);
 }
 
@@ -6518,8 +6518,11 @@ function entity_uri($entity_type, $entit
   // This check enables the URI of an entity to be easily overridden from what
   // the callback for the entity type or bundle would return, and it helps
   // minimize performance overhead when entity_uri() is called multiple times
-  // for the same entity.
-  if (!isset($entity->uri)) {
+  // for the same entity. The check is entity type specific, because in some
+  // cases, code uses an entity object of one type as a mock entity of another
+  // type (for example, node and comment entities are passed to
+  // theme('username') which treats the passed entity as a mock user entity).
+  if (!isset($entity->uri[$entity_type])) {
     $info = entity_get_info($entity_type);
     list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
 
@@ -6539,16 +6542,58 @@ function entity_uri($entity_type, $entit
     // entity's 'uri' property to FALSE to indicate that it is known to not have
     // a URI.
     if (isset($uri_callback) && function_exists($uri_callback)) {
-      $entity->uri = $uri_callback($entity);
-      if (!isset($entity->uri['options'])) {
-        $entity->uri['options'] = array();
-      }
+      $uri = $uri_callback($entity) + array('options' => array());
+      // Ensure 'path' is first and 'options' is second, so that the URI can be
+      // used as the value of $form_state['redirect'].
+      $entity->uri[$entity_type] = array('path' => $uri['path'], 'options' => $uri['options']);
     }
     else {
-      $entity->uri = FALSE;
+      $entity->uri[$entity_type] = FALSE;
     }
   }
-  return $entity->uri ? $entity->uri : NULL;
+  return $entity->uri[$entity_type] ? $entity->uri[$entity_type] : NULL;
+}
+
+/**
+ * Returns the URL of an entity.
+ *
+ * @param $entity_type
+ *   The entity type; e.g. 'node' or 'user'.
+ * @param $entity
+ *   The entity for which to generate a URL.
+ * @param $options
+ *   Options to pass to url() in addition to the ones returned by entity_uri().
+ * @return
+ *   A URL string as returned by url().
+ *
+ * @see entity_uri()
+ * @see url()
+ */
+function entity_url($entity_type, $entity, $options = array()) {
+  $uri = entity_uri($entity_type, $entity);
+  return url($uri['path'], array_merge($uri['options'], $options));
+}
+
+/**
+ * Formats an entity link as an HTML anchor tag.
+ *
+ * @param $text
+ *   The link text for the anchor tag.
+ * @param $entity_type
+ *   The entity type; e.g. 'node' or 'user'.
+ * @param $entity
+ *   The entity for which to generate a link.
+ * @param $options
+ *   Options to pass to l() in addition to the ones returned by entity_uri().
+ * @return
+ *   An HTML anchor tag as returned by l().
+ *
+ * @see entity_uri()
+ * @see l()
+ */
+function entity_l($text, $entity_type, $entity, $options = array()) {
+  $uri = entity_uri($entity_type, $entity);
+  return l($text, $uri['path'], array_merge($uri['options'], $options));
 }
 
 /**
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.596
diff -u -p -r1.596 theme.inc
--- includes/theme.inc	30 Apr 2010 20:07:03 -0000	1.596
+++ includes/theme.inc	4 May 2010 02:02:16 -0000
@@ -2521,7 +2521,7 @@ function template_preprocess_username(&$
   if ($variables['uid'] && $variables['profile_access']) {
     // We are linking to a local user.
     $variables['link_attributes'] = array('title' => t('View user profile.'));
-    $variables['link_path'] = 'user/' . $variables['uid'];
+    list($variables['link_path'], $variables['link_options']) = array_values(entity_uri('user', $account));
   }
   elseif (!empty($account->homepage)) {
     // Like the 'class' attribute, the 'rel' attribute can hold a
Index: modules/book/book.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.admin.inc,v
retrieving revision 1.35
diff -u -p -r1.35 book.admin.inc
--- modules/book/book.admin.inc	1 May 2010 08:12:22 -0000	1.35
+++ modules/book/book.admin.inc	4 May 2010 02:02:17 -0000
@@ -132,7 +132,7 @@ function book_admin_edit_submit($form, &
         $node->log = t('Title changed from %original to %current.', array('%original' => $node->title, '%current' => $values['title']));
 
         node_save($node);
-        watchdog('content', 'book: updated %title.', array('%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
+        watchdog('content', 'book: updated %title.', array('%title' => $node->title), WATCHDOG_NOTICE, entity_l(t('view'), 'node', $node));
       }
     }
   }
Index: modules/book/book.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.pages.inc,v
retrieving revision 1.25
diff -u -p -r1.25 book.pages.inc
--- modules/book/book.pages.inc	13 Mar 2010 06:55:50 -0000	1.25
+++ modules/book/book.pages.inc	4 May 2010 02:02:17 -0000
@@ -154,7 +154,7 @@ function book_remove_button_submit($form
  */
 function book_outline_form_submit($form, &$form_state) {
   $node = $form['#node'];
-  $form_state['redirect'] = "node/" . $node->nid;
+  $form_state['redirect'] = entity_uri('node', $node);
   $book_link = $form_state['values']['book'];
   if (!$book_link['bid']) {
     drupal_set_message(t('No changes were made'));
@@ -197,7 +197,8 @@ function book_remove_form($form, &$form_
     $description = t('%title may be added to hierarchy again using the Outline tab.', $title);
   }
 
-  return confirm_form($form, t('Are you sure you want to remove %title from the book hierarchy?', $title), 'node/' . $node->nid, $description, t('Remove'));
+  $uri = entity_uri('node', $node);
+  return confirm_form($form, t('Are you sure you want to remove %title from the book hierarchy?', $title), array('path' => $uri['path']) + $uri['options'], $description, t('Remove'));
 }
 
 /**
@@ -215,7 +216,7 @@ function book_remove_form_submit($form, 
       ->execute();
     drupal_set_message(t('The post has been removed from the book.'));
   }
-  $form_state['redirect'] = 'node/' . $node->nid;
+  $form_state['redirect'] = entity_uri('node', $node);
 }
 
 /**
Index: modules/comment/comment.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.admin.inc,v
retrieving revision 1.46
diff -u -p -r1.46 comment.admin.inc
--- modules/comment/comment.admin.inc	31 Mar 2010 11:49:50 -0000	1.46
+++ modules/comment/comment.admin.inc	4 May 2010 02:02:17 -0000
@@ -98,13 +98,15 @@ function comment_admin_overview($form, &
     // Remove the first node title from the node_titles array and attach to
     // the comment.
     $comment->node_title = array_shift($node_titles);
+    $uri = entity_uri('comment', $comment);
+    $node_uri = entity_uri('node', entity_create_stub_entity('node', array($comment->nid, NULL, $comment->node_type)));
     $options[$comment->cid] = array(
       'subject' => array(
         'data' => array(
           '#type' => 'link',
           '#title' => $comment->subject,
-          '#href' => 'comment/' . $comment->cid,
-          '#options' => array('attributes' => array('title' => truncate_utf8($comment->comment_body[LANGUAGE_NONE][0]['value'], 128)), 'fragment' => 'comment-' . $comment->cid),
+          '#href' => $uri['path'],
+          '#options' => $uri['options'] + array('attributes' => array('title' => truncate_utf8($comment->comment_body[LANGUAGE_NONE][0]['value'], 128))),
         ),
       ),
       'author' => theme('username', array('account' => $comment)),
@@ -112,8 +114,8 @@ function comment_admin_overview($form, &
         'data' => array(
           '#type' => 'link',
           '#title' => $comment->node_title,
-          '#href' => 'node/' . $comment->nid,
-        ),
+          '#href' => $node_uri['path'],
+        ) + $node_uri['options'],
       ),
       'changed' => format_date($comment->changed, 'short'),
       'operations' => array(
@@ -255,12 +257,13 @@ function comment_confirm_delete_page($ci
  */
 function comment_confirm_delete($form, &$form_state, $comment) {
   $form['#comment'] = $comment;
+  $node_uri = entity_uri('node', entity_create_stub_entity('node', array($comment->nid, NULL, $comment->node_type)));
   // Always provide entity id in the same form key as in the entity edit form.
   $form['cid'] = array('#type' => 'value', '#value' => $comment->cid);
   return confirm_form(
     $form,
     t('Are you sure you want to delete the comment %title?', array('%title' => $comment->subject)),
-    'node/' . $comment->nid,
+    array('path' => $node_uri['path']) + $node_uri['options'],
     t('Any replies to this comment will be lost. This action cannot be undone.'),
     t('Delete'),
     t('Cancel'),
@@ -279,5 +282,5 @@ function comment_confirm_delete_submit($
   // Clear the cache so an anonymous user sees that his comment was deleted.
   cache_clear_all();
 
-  $form_state['redirect'] = "node/$comment->nid";
+  $form_state['redirect'] = entity_uri('node', entity_create_stub_entity('node', array($comment->nid, NULL, $comment->node_type)));
 }
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.872
diff -u -p -r1.872 comment.module
--- modules/comment/comment.module	28 Apr 2010 16:08:51 -0000	1.872
+++ modules/comment/comment.module	4 May 2010 02:02:17 -0000
@@ -576,7 +576,7 @@ function theme_comment_block() {
   $items = array();
   $number = variable_get('comment_block_count', 10);
   foreach (comment_get_recent($number) as $comment) {
-    $items[] = l($comment->subject, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) .'<span>'. t('@time ago', array('@time' => format_interval(REQUEST_TIME - $comment->changed))) .'</span>';
+    $items[] = entity_l($comment->subject, 'comment', $comment) .'<span>'. t('@time ago', array('@time' => format_interval(REQUEST_TIME - $comment->changed))) .'</span>';
   }
 
   if ($items) {
@@ -589,6 +589,7 @@ function theme_comment_block() {
  */
 function comment_node_view($node, $view_mode) {
   $links = array();
+  $node_uri = entity_uri('node', $node);
 
   if ($node->comment) {
     if ($view_mode == 'rss') {
@@ -596,7 +597,7 @@ function comment_node_view($node, $view_
         // Add a comments RSS element which is a URL to the comments of this node.
         $node->rss_elements[] = array(
           'key' => 'comments',
-          'value' => url('node/' . $node->nid, array('fragment' => 'comments', 'absolute' => TRUE))
+          'value' => entity_url('node', $node, array('fragment' => 'comments', 'absolute' => TRUE))
         );
       }
     }
@@ -608,22 +609,22 @@ function comment_node_view($node, $view_
         if (!empty($node->comment_count)) {
           $links['comment_comments'] = array(
             'title' => format_plural($node->comment_count, '1 comment', '@count comments'),
-            'href' => "node/$node->nid",
+            'href' => $node_uri['path'],
             'attributes' => array('title' => t('Jump to the first comment of this posting.')),
             'fragment' => 'comments',
             'html' => TRUE,
-          );
+          ) + $node_uri['options'];
 
           $new = comment_num_new($node->nid);
           if ($new) {
             $links['comment_new_comments'] = array(
               'title' => format_plural($new, '1 new comment', '@count new comments'),
-              'href' => "node/$node->nid",
+              'href' => $node_uri['path'],
               'query' => comment_new_page_count($node->comment_count, $new, $node),
               'attributes' => array('title' => t('Jump to the first new comment of this posting.')),
               'fragment' => 'new',
               'html' => TRUE,
-            );
+            ) + $node_uri['options'];
           }
         }
         else {
@@ -661,7 +662,7 @@ function comment_node_view($node, $view_
             $links['comment_add']['href'] = "comment/reply/$node->nid";
           }
           else {
-            $links['comment_add']['href'] = "node/$node->nid";
+            $links['comment_add'] += array('href' => $node_uri['path']) + $node_uri['options'];
           }
         }
         else {
@@ -2121,7 +2122,7 @@ function comment_form_submit($form, &$fo
     $form_state['values']['cid'] = $comment->cid;
 
     // Add an entry to the watchdog log.
-    watchdog('content', 'Comment posted: %subject.', array('%subject' => $comment->subject), WATCHDOG_NOTICE, l(t('view'), 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)));
+    watchdog('content', 'Comment posted: %subject.', array('%subject' => $comment->subject), WATCHDOG_NOTICE, entity_l(t('view'), 'comment', $comment));
 
     // Explain the approval queue if necessary.
     if ($comment->status == COMMENT_NOT_PUBLISHED) {
@@ -2139,13 +2140,13 @@ function comment_form_submit($form, &$fo
       $query['page'] = $page;
     }
     // Redirect to the newly posted comment.
-    $redirect = array('node/' . $node->nid, array('query' => $query, 'fragment' => 'comment-' . $comment->cid));
+    $redirect = entity_uri('comment', $comment);
   }
   else {
     watchdog('content', 'Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject), WATCHDOG_WARNING);
     drupal_set_message(t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject)), 'error');
     // Redirect the user to the node they are commenting on.
-    $redirect = 'node/' . $node->nid;
+    $redirect = entity_uri('node', $node);
   }
   unset($form_state['rebuild']);
   $form_state['redirect'] = $redirect;
@@ -2172,9 +2173,8 @@ function template_preprocess_comment(&$v
   $variables['picture']   = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : '';
   $variables['signature'] = $comment->signature;
 
-  $uri = entity_uri('comment', $comment);
-  $variables['title']     = l($comment->subject, $uri['path'], $uri['options']);
-  $variables['permalink'] = l('#', $uri['path'], $uri['options']);
+  $variables['title']     = entity_l($comment->subject, 'comment', $comment);
+  $variables['permalink'] = entity_l('#', 'comment', $comment);
 
   // Preprocess fields.
   field_attach_preprocess('comment', $comment, $variables['elements'], $variables);
@@ -2245,7 +2245,8 @@ function theme_comment_post_forbidden($v
         $destination = array('destination' => "comment/reply/$node->nid#comment-form");
       }
       else {
-        $destination = array('destination' => "node/$node->nid#comment-form");
+        $node_uri = entity_uri('node', $node);
+        $destination = array('destination' => $node_uri['path'] . '#comment-form');
       }
 
       if (variable_get('user_register', 1)) {
Index: modules/comment/comment.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.pages.inc,v
retrieving revision 1.38
diff -u -p -r1.38 comment.pages.inc
--- modules/comment/comment.pages.inc	13 Apr 2010 15:13:41 -0000	1.38
+++ modules/comment/comment.pages.inc	4 May 2010 02:02:17 -0000
@@ -29,9 +29,10 @@
  */
 function comment_reply($node, $pid = NULL) {
   // Set the breadcrumb trail.
-  drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/' . $node->nid)));
+  drupal_set_breadcrumb(array(l(t('Home'), NULL), entity_l($node->title, 'node', $node)));
   $op = isset($_POST['op']) ? $_POST['op'] : '';
   $build = array();
+  $node_uri = entity_uri('node', $node);
 
   if (user_access('access comments')) {
     // The user is previewing a comment prior to submitting it.
@@ -41,7 +42,7 @@ function comment_reply($node, $pid = NUL
       }
       else {
         drupal_set_message(t('You are not authorized to post comments.'), 'error');
-        drupal_goto("node/$node->nid");
+        drupal_goto($node_uri['path'], $node_uri['options']);
       }
     }
     else {
@@ -58,7 +59,7 @@ function comment_reply($node, $pid = NUL
           if ($comment->nid != $node->nid) {
             // Attempting to reply to a comment not belonging to the current nid.
             drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
-            drupal_goto("node/$node->nid");
+            drupal_goto($node_uri['path'], $node_uri['options']);
           }
           // Display the parent comment
           $comment->node_type = 'comment_node_' . $node->type;
@@ -68,7 +69,7 @@ function comment_reply($node, $pid = NUL
         }
         else {
           drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
-          drupal_goto("node/$node->nid");
+          drupal_goto($node_uri['path'], $node_uri['options']);
         }
       }
       // This is the case where the comment is in response to a node. Display the node.
@@ -79,7 +80,7 @@ function comment_reply($node, $pid = NUL
       // Should we show the reply box?
       if ($node->comment != COMMENT_NODE_OPEN) {
         drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
-        drupal_goto("node/$node->nid");
+        drupal_goto($node_uri['path'], $node_uri['options']);
       }
       elseif (user_access('post comments')) {
         $edit = array('nid' => $node->nid, 'pid' => $pid);
@@ -87,13 +88,13 @@ function comment_reply($node, $pid = NUL
       }
       else {
         drupal_set_message(t('You are not authorized to post comments.'), 'error');
-        drupal_goto("node/$node->nid");
+        drupal_goto($node_uri['path'], $node_uri['options']);
       }
     }
   }
   else {
     drupal_set_message(t('You are not authorized to view comments.'), 'error');
-    drupal_goto("node/$node->nid");
+    drupal_goto($node_uri['path'], $node_uri['options']);
   }
 
   return $build;
Index: modules/comment/comment.tokens.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.tokens.inc,v
retrieving revision 1.11
diff -u -p -r1.11 comment.tokens.inc
--- modules/comment/comment.tokens.inc	20 Apr 2010 09:48:06 -0000	1.11
+++ modules/comment/comment.tokens.inc	4 May 2010 02:02:17 -0000
@@ -187,8 +187,7 @@ function comment_tokens($type, $tokens, 
 
         // Comment related URLs.
         case 'url':
-          $url_options['fragment']  = 'comment-' . $comment->cid;
-          $replacements[$original] = url('comment/' . $comment->cid, $url_options);
+          $replacements[$original] = entity_url('comment', $comment, $url_options);
           break;
 
         case 'edit-url':
Index: modules/contact/contact.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v
retrieving revision 1.147
diff -u -p -r1.147 contact.module
--- modules/contact/contact.module	13 Apr 2010 15:13:41 -0000	1.147
+++ modules/contact/contact.module	4 May 2010 02:02:17 -0000
@@ -178,7 +178,7 @@ function contact_mail($key, &$message, $
     '!category' => isset($params['category']['category']) ? $params['category']['category'] : '',
     '!form-url' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language)),
     '!sender-name' => format_username($params['sender']),
-    '!sender-url' => $params['sender']->uid ? url('user/' . $params['sender']->uid, array('absolute' => TRUE, 'language' => $language)) : $params['sender']->mail,
+    '!sender-url' => $params['sender']->uid ? entity_url('user', $params['sender'], array('absolute' => TRUE, 'language' => $language)) : $params['sender']->mail,
   );
 
   switch ($key) {
Index: modules/contact/contact.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.pages.inc,v
retrieving revision 1.43
diff -u -p -r1.43 contact.pages.inc
--- modules/contact/contact.pages.inc	24 Apr 2010 14:49:13 -0000	1.43
+++ modules/contact/contact.pages.inc	4 May 2010 02:02:17 -0000
@@ -286,5 +286,5 @@ function contact_personal_form_submit($f
 
   // Jump to the contacted user's profile page.
   drupal_set_message(t('Your message has been sent.'));
-  $form_state['redirect'] = user_access('access user profiles') ? 'user/' . $values['recipient']->uid : '';
+  $form_state['redirect'] = user_access('access user profiles') ? entity_uri('user', $values['recipient']) : '';
 }
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.565
diff -u -p -r1.565 forum.module
--- modules/forum/forum.module	28 Apr 2010 05:54:55 -0000	1.565
+++ modules/forum/forum.module	4 May 2010 02:02:19 -0000
@@ -1102,7 +1102,7 @@ function template_preprocess_forum_topic
       }
       else {
         $variables['topics'][$id]->moved = FALSE;
-        $variables['topics'][$id]->title = l($topic->title, "node/$topic->nid");
+        $variables['topics'][$id]->title = entity_l($topic->title, 'node', $topic);
         $variables['topics'][$id]->message = '';
       }
       $topic->uid = $topic->last_comment_uid ? $topic->last_comment_uid : $topic->uid;
@@ -1113,7 +1113,7 @@ function template_preprocess_forum_topic
       $variables['topics'][$id]->new_url = '';
       if ($topic->new_replies) {
         $variables['topics'][$id]->new_text = format_plural($topic->new_replies, '1 new', '@count new');
-        $variables['topics'][$id]->new_url = url("node/$topic->nid", array('query' => comment_new_page_count($topic->comment_count, $topic->new_replies, $topic), 'fragment' => 'new'));
+        $variables['topics'][$id]->new_url = entity_url('node', $topic, array('query' => comment_new_page_count($topic->comment_count, $topic->new_replies, $topic), 'fragment' => 'new'));
       }
 
     }
Index: modules/node/node.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v
retrieving revision 1.94
diff -u -p -r1.94 node.admin.inc
--- modules/node/node.admin.inc	24 Apr 2010 14:49:14 -0000	1.94
+++ modules/node/node.admin.inc	4 May 2010 02:02:19 -0000
@@ -344,7 +344,7 @@ function _node_mass_update_batch_process
     $node = _node_mass_update_helper($nid, $updates);
 
     // Store result for post-processing in the finished callback.
-    $context['results'][] = l($node->title, 'node/' . $node->nid);
+    $context['results'][] = entity_l($node->title, 'node', $node);
 
     // Update our progress information.
     $context['sandbox']['progress']++;
@@ -464,13 +464,14 @@ function node_admin_nodes() {
   $options = array();
   foreach ($nodes as $node) {
     $l_options = $node->language != LANGUAGE_NONE ? array('language' => $languages[$node->language]) : array();
+    $uri = entity_uri('node', $node);
     $options[$node->nid] = array(
       'title' => array(
         'data' => array(
           '#type' => 'link',
           '#title' => $node->title,
-          '#href' => 'node/' . $node->nid,
-          '#options' => $l_options,
+          '#href' => $uri['path'],
+          '#options' => array_merge($uri['options'], $l_options),
           '#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))),
         ),
       ),
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1264
diff -u -p -r1.1264 node.module
--- modules/node/node.module	22 Apr 2010 09:12:35 -0000	1.1264
+++ modules/node/node.module	4 May 2010 02:02:19 -0000
@@ -274,7 +274,7 @@ function node_title_list($result, $title
   $items = array();
   $num_rows = FALSE;
   foreach ($result as $node) {
-    $items[] = l($node->title, 'node/' . $node->nid, !empty($node->comment_count) ? array('attributes' => array('title' => format_plural($node->comment_count, '1 comment', '@count comments'))) : array());
+    $items[] = entity_l($node->title, 'node', $node, !empty($node->comment_count) ? array('attributes' => array('title' => format_plural($node->comment_count, '1 comment', '@count comments'))) : array());
     $num_rows = TRUE;
   }
 
@@ -1277,11 +1277,12 @@ function node_build_content($node, $view
   // to know when a teaser view is different than a full view.
   $links = array();
   if ($view_mode == 'teaser') {
+    $uri = entity_uri('node', $node);
     $links['node_readmore'] = array(
       'title' => t('Read more'),
-      'href' => 'node/' . $node->nid,
+      'href' => $uri['path'],
       'attributes' => array('rel' => 'tag', 'title' => strip_tags($node->title))
-    );
+    ) + $uri['options'];
   }
   $node->content['links']['node'] = array(
     '#theme' => 'links__node',
@@ -1350,8 +1351,7 @@ function template_preprocess_node(&$vari
   $variables['date']      = format_date($node->created);
   $variables['name']      = theme('username', array('account' => $node));
 
-  $uri = entity_uri('node', $node);
-  $variables['node_url']  = url($uri['path'], $uri['options']);
+  $variables['node_url']  = entity_url('node', $node);
   $variables['title']     = check_plain($node->title);
   $variables['page']      = node_is_page($node);
 
@@ -1583,9 +1583,8 @@ function node_search_execute($keys = NUL
 
     $extra = module_invoke_all('node_search_result', $node);
 
-    $uri = entity_uri('node', $node);
     $results[] = array(
-      'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE))),
+      'link' => entity_url('node', $node, array('absolute' => TRUE)),
       'type' => check_plain(node_type_get_name($node)),
       'title' => $node->title,
       'user' => theme('username', array('account' => $node)),
@@ -2187,7 +2186,7 @@ function theme_node_recent_content($vari
   $node = $variables['node'];
 
   $output = '<div class="node-title">';
-  $output .= l($node->title, 'node/' . $node->nid);
+  $output .= entity_l($node->title, 'node', $node);
   $output .= theme('mark', array('type' => node_mark($node->nid, $node->changed)));
   $output .= '</div><div class="node-author">';
   $output .= theme('username', array('account' => user_load($node->uid)));
@@ -2386,7 +2385,7 @@ function node_feed($nids = FALSE, $chann
   foreach ($nodes as $node) {
     $item_text = '';
 
-    $node->link = url("node/$node->nid", array('absolute' => TRUE));
+    $node->link = entity_url('node', $node, array('absolute' => TRUE));
     $node->rss_namespaces = array();
     $node->rss_elements = array(
       array('key' => 'pubDate', 'value' => gmdate('r', $node->created)),
@@ -2511,11 +2510,10 @@ function node_page_default() {
  */
 function node_page_view($node) {
   drupal_set_title($node->title);
-  $uri = entity_uri('node', $node);
   // Set the node path as the canonical URL to prevent duplicate content.
-  drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
+  drupal_add_html_head_link(array('rel' => 'canonical', 'href' => entity_url('node', $node)), TRUE);
   // Set the non-aliased path as a default shortlink.
-  drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
+  drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => entity_url('node', $node, array('alias' => TRUE))), TRUE);
   return node_show($node);
 }
 
Index: modules/node/node.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v
retrieving revision 1.123
diff -u -p -r1.123 node.pages.inc
--- modules/node/node.pages.inc	24 Apr 2010 14:49:14 -0000	1.123
+++ modules/node/node.pages.inc	4 May 2010 02:02:19 -0000
@@ -380,7 +380,7 @@ function node_form_submit($form, &$form_
   $node = node_form_submit_build_node($form, $form_state);
   $insert = empty($node->nid);
   node_save($node);
-  $node_link = l(t('view'), 'node/' . $node->nid);
+  $node_link = entity_l(t('view'), 'node', $node);
   $watchdog_args = array('@type' => $node->type, '%title' => $node->title);
   $t_args = array('@type' => node_type_get_name($node), '%title' => $node->title);
 
@@ -396,7 +396,7 @@ function node_form_submit($form, &$form_
     unset($form_state['rebuild']);
     $form_state['values']['nid'] = $node->nid;
     $form_state['nid'] = $node->nid;
-    $form_state['redirect'] = 'node/' . $node->nid;
+    $form_state['redirect'] = entity_uri('node', $node);
   }
   else {
     // In the unlikely case something went wrong on save, the node will be
@@ -431,9 +431,10 @@ function node_delete_confirm($form, &$fo
   $form['#node'] = $node;
   // Always provide entity id in the same form key as in the entity edit form.
   $form['nid'] = array('#type' => 'value', '#value' => $node->nid);
+  $uri = entity_uri('node', $node);
   return confirm_form($form,
     t('Are you sure you want to delete %title?', array('%title' => $node->title)),
-    'node/' . $node->nid,
+    array('path' => $uri['path']) + $uri['options'],
     t('This action cannot be undone.'),
     t('Delete'),
     t('Cancel')
@@ -478,7 +479,7 @@ function node_revision_overview($node) {
     $operations = array();
 
     if ($revision->current_vid > 0) {
-      $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'short'), "node/$node->nid"), '!username' => theme('username', array('account' => $revision))))
+      $row[] = array('data' => t('!date by !username', array('!date' => entity_l(format_date($revision->timestamp, 'short'), 'node', $node), '!username' => theme('username', array('account' => $revision))))
                                . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : ''),
                      'class' => array('revision-current'));
       $operations[] = array('data' => drupal_placeholder(array('text' => t('current revision'))), 'class' => array('revision-current'), 'colspan' => 2);
Index: modules/node/node.tokens.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.tokens.inc,v
retrieving revision 1.14
diff -u -p -r1.14 node.tokens.inc
--- modules/node/node.tokens.inc	20 Apr 2010 09:48:06 -0000	1.14
+++ modules/node/node.tokens.inc	4 May 2010 02:02:19 -0000
@@ -157,7 +157,7 @@ function node_tokens($type, $tokens, arr
           break;
 
         case 'url':
-          $replacements[$original] = url('node/' . $node->nid, $url_options);
+          $replacements[$original] = entity_url('node', $node, $url_options);
           break;
 
         case 'edit-url':
Index: modules/poll/poll.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.pages.inc,v
retrieving revision 1.27
diff -u -p -r1.27 poll.pages.inc
--- modules/poll/poll.pages.inc	9 Jan 2010 21:54:01 -0000	1.27
+++ modules/poll/poll.pages.inc	4 May 2010 02:02:19 -0000
@@ -39,7 +39,7 @@ function poll_page() {
 
   $output = '<ul>';
   foreach ($queried_nodes as $node) {
-    $output .= '<li>' . l($node->title, "node/$node->nid") . ' - ' . format_plural($node->votes, '1 vote', '@count votes') . ' - ' . ($node->active ? t('open') : t('closed')) . '</li>';
+    $output .= '<li>' . entity_l($node->title, 'node', $node) . ' - ' . format_plural($node->votes, '1 vote', '@count votes') . ' - ' . ($node->active ? t('open') : t('closed')) . '</li>';
   }
   $output .= '</ul>';
   $output .= theme("pager", array('tags' => NULL));
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.290
diff -u -p -r1.290 profile.module
--- modules/profile/profile.module	23 Apr 2010 04:32:16 -0000	1.290
+++ modules/profile/profile.module	4 May 2010 02:02:19 -0000
@@ -199,7 +199,7 @@ function profile_block_view($delta = '')
       }
 
       if (isset($use_fields['user_profile']) && $use_fields['user_profile']) {
-        $output .= '<div>' . l(t('View full user profile'), 'user/' . $account->uid) . '</div>';
+        $output .= '<div>' . entity_l(t('View full user profile'), 'user', $account) . '</div>';
       }
     }
 
Index: modules/rdf/rdf.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/rdf/rdf.module,v
retrieving revision 1.39
diff -u -p -r1.39 rdf.module
--- modules/rdf/rdf.module	22 Apr 2010 21:41:09 -0000	1.39
+++ modules/rdf/rdf.module	4 May 2010 02:02:20 -0000
@@ -399,9 +399,12 @@ function rdf_entity_load($entities, $typ
 function rdf_comment_load($comments) {
   foreach ($comments as $comment) {
     $comment->rdf_data['date'] = rdf_rdfa_attributes($comment->rdf_mapping['created'], $comment->created);
-    $comment->rdf_data['nid_uri'] = url('node/' . $comment->nid);
+    $comment->rdf_data['nid_uri'] = entity_url('node', entity_create_stub_entity('node', array($comment->nid, NULL, $comment->node_type)));
     if ($comment->pid) {
-      $comment->rdf_data['pid_uri'] = url('comment/' . $comment->pid, array('fragment' => 'comment-' . $comment->pid));
+      // Rather than use a database query to load the parent comment, we assume
+      // that the comment's parent is for the same node, and therefore, the same
+      // node type.
+      $comment->rdf_data['pid_uri'] = entity_url('comment', entity_create_stub_entity('comment', array($comment->pid, NULL, $comment->node_type)));
     }
   }
 }
@@ -564,30 +567,29 @@ function rdf_preprocess_field(&$variable
  */
 function rdf_preprocess_user_profile(&$variables) {
   $account = $variables['elements']['#account'];
-  $uri = entity_uri('user', $account);
 
   // Adds RDFa markup to the user profile page. Fields displayed in this page
   // will automatically describe the user.  
   if (!empty($account->rdf_mapping['rdftype'])) {
     $variables['attributes_array']['typeof'] = $account->rdf_mapping['rdftype'];
-    $variables['attributes_array']['about'] = url($uri['path'], $uri['options']);
+    $variables['attributes_array']['about'] = entity_url('user', $account);
   }
   // Adds the relationship between the sioc:UserAccount and the foaf:Person who
   // holds the account.
   $account_holder_meta = array(
     '#tag' => 'meta',
     '#attributes' => array(
-      'about' => url($uri['path'], array_merge($uri['options'], array('fragment' => 'me'))),
+      'about' => entity_url('user', $account, array('fragment' => 'me')),
       'typeof' => array('foaf:Person'),
       'rel' => array('foaf:account'),
-      'resource' => url($uri['path'], $uri['options']),
+      'resource' => entity_url('user', $account),
     ),
   );
   // Adds the markup for username.
   $username_meta = array(
     '#tag' => 'meta',
     '#attributes' => array(
-      'about' => url($uri['path'], $uri['options']),
+      'about' => entity_url('user', $account),
       'property' => $account->rdf_mapping['name']['predicates'],
       'content' => $account->name,
     )
@@ -625,7 +627,7 @@ function rdf_preprocess_username(&$varia
   // a user profile URI for it (only a homepage which cannot be used as user
   // profile in RDF).
   if ($variables['uid'] > 0) {
-    $variables['attributes_array']['about'] = url('user/' . $variables['uid']);
+    $variables['attributes_array']['about'] = entity_url('user', $variables['account']);
   }
 
   $attributes = array();
@@ -660,8 +662,7 @@ function rdf_preprocess_comment(&$variab
     // Adds RDFa markup to the comment container. The about attribute specifies
     // the URI of the resource described within the HTML element, while the
     // typeof attribute indicates its RDF type (e.g. sioc:Post, etc.).
-    $uri = entity_uri('comment', $comment);
-    $variables['attributes_array']['about'] = url($uri['path'], $uri['options']);
+    $variables['attributes_array']['about'] = entity_url('comment', $comment);
     $variables['attributes_array']['typeof'] = $comment->rdf_mapping['rdftype'];
   }
 
@@ -709,7 +710,7 @@ function rdf_preprocess_taxonomy_term(&$
   $term_label_meta = array(
       '#tag' => 'meta',
       '#attributes' => array(
-        'about' => url('taxonomy/term/' . $term->tid),
+        'about' => entity_url('taxonomy_term', $term),
         'typeof' => $term->rdf_mapping['rdftype'],
         'property' => $term->rdf_mapping['name']['predicates'],
         'content' => $term->name,
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.164
diff -u -p -r1.164 system.api.php
--- modules/system/system.api.php	30 Apr 2010 19:21:52 -0000	1.164
+++ modules/system/system.api.php	4 May 2010 02:02:21 -0000
@@ -1986,7 +1986,7 @@ function hook_mail($key, &$message, $par
     $node = $params['node'];
     $variables += array(
       '%uid' => $node->uid,
-      '%node_url' => url('node/' . $node->nid, array('absolute' => TRUE)),
+      '%node_url' => entity_url('node', $node, array('absolute' => TRUE)),
       '%node_type' => node_type_get_name($node),
       '%title' => $node->title,
       '%teaser' => $node->teaser,
Index: modules/taxonomy/taxonomy.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v
retrieving revision 1.103
diff -u -p -r1.103 taxonomy.admin.inc
--- modules/taxonomy/taxonomy.admin.inc	28 Apr 2010 19:36:01 -0000	1.103
+++ modules/taxonomy/taxonomy.admin.inc	4 May 2010 02:02:21 -0000
@@ -358,7 +358,8 @@ function taxonomy_overview_terms($form, 
       unset($form[$key]['#term']['parents'], $term->parents);
     }
 
-    $form[$key]['view'] = array('#type' => 'link', '#title' => $term->name, '#href' => "taxonomy/term/$term->tid");
+    $uri = entity_uri('taxonomy_term', $term);
+    $form[$key]['view'] = array('#type' => 'link', '#title' => $term->name, '#href' => $uri['path'], '#options' => $uri['options']);
     if ($vocabulary->hierarchy < 2 && count($tree) > 1) {
       $form['#parent_fields'] = TRUE;
       $form[$key]['tid'] = array(
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.588
diff -u -p -r1.588 taxonomy.module
--- modules/taxonomy/taxonomy.module	30 Apr 2010 12:52:10 -0000	1.588
+++ modules/taxonomy/taxonomy.module	4 May 2010 02:02:21 -0000
@@ -608,8 +608,7 @@ function template_preprocess_taxonomy_te
   $variables['term'] = $variables['elements']['#term'];
   $term = $variables['term'];
 
-  $uri = entity_uri('taxonomy_term', $term);
-  $variables['term_url']  = url($uri['path'], $uri['options']);
+  $variables['term_url']  = entity_url('taxonomy_term', $term);
   $variables['term_name'] = check_plain($term->name);
   $variables['page']      = taxonomy_term_is_page($term);
 
Index: modules/taxonomy/taxonomy.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v
retrieving revision 1.51
diff -u -p -r1.51 taxonomy.pages.inc
--- modules/taxonomy/taxonomy.pages.inc	10 Feb 2010 06:28:10 -0000	1.51
+++ modules/taxonomy/taxonomy.pages.inc	4 May 2010 02:02:21 -0000
@@ -22,7 +22,7 @@ function taxonomy_term_page($term) {
   $breadcrumb = array();
   while ($parents = taxonomy_get_parents($current->tid)) {
     $current = array_shift($parents);
-    $breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid);
+    $breadcrumb[] = entity_l($current->name, 'taxonomy_term', $current);
   }
   $breadcrumb[] = l(t('Home'), NULL);
   $breadcrumb = array_reverse($breadcrumb);
@@ -60,7 +60,7 @@ function taxonomy_term_page($term) {
  *   The taxonomy term.
  */
 function taxonomy_term_feed($term) {
-  $channel['link'] = url('taxonomy/term/' . $term->tid, array('absolute' => TRUE));
+  $channel['link'] = entity_url('taxonomy_term', $term, array('absolute' => TRUE));
   $channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $term->name;
   // Only display the description if we have a single term, to avoid clutter and confusion.
   // HTML will be removed from feed description.
Index: modules/taxonomy/taxonomy.tokens.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.tokens.inc,v
retrieving revision 1.6
diff -u -p -r1.6 taxonomy.tokens.inc
--- modules/taxonomy/taxonomy.tokens.inc	29 Jan 2010 22:56:54 -0000	1.6
+++ modules/taxonomy/taxonomy.tokens.inc	4 May 2010 02:02:21 -0000
@@ -119,7 +119,7 @@ function taxonomy_tokens($type, $tokens,
           break;
 
         case 'url':
-          $replacements[$original] = url('taxonomy/term/' . $term->tid, array('absolute' => TRUE));
+          $replacements[$original] = entity_url('taxonomy_term', $term, array('absolute' => TRUE));
           break;
 
         case 'node-count':
Index: modules/tracker/tracker.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/tracker/tracker.pages.inc,v
retrieving revision 1.31
diff -u -p -r1.31 tracker.pages.inc
--- modules/tracker/tracker.pages.inc	14 Jan 2010 06:23:40 -0000	1.31
+++ modules/tracker/tracker.pages.inc	4 May 2010 02:02:22 -0000
@@ -55,13 +55,13 @@ function tracker_page($account = NULL, $
 
         if ($new = comment_num_new($node->nid)) {
           $comments .= '<br />';
-          $comments .= l(format_plural($new, '1 new', '@count new'), 'node/'. $node->nid, array('fragment' => 'new'));
+          $comments .= entity_l(format_plural($new, '1 new', '@count new'), 'node', $node, array('fragment' => 'new'));
         }
       }
 
       $row = array(
         'type' => check_plain(node_type_get_name($node->type)),
-        'title' => array('data' => l($node->title, 'node/' . $node->nid) . ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed)))),
+        'title' => array('data' => entity_l($node->title, 'node', $node) . ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed)))),
         'author' => array('data' => theme('username', array('account' => $node))),
         'replies' => array('class' => array('replies'), 'data' => $comments),
         'last updated' => array('data' => t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_activity)))),
Index: modules/translation/translation.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/translation/translation.pages.inc,v
retrieving revision 1.15
diff -u -p -r1.15 translation.pages.inc
--- modules/translation/translation.pages.inc	30 Jan 2010 07:59:26 -0000	1.15
+++ modules/translation/translation.pages.inc	4 May 2010 02:02:22 -0000
@@ -33,7 +33,7 @@ function translation_node_overview($node
       // Existing translation in the translation set: display status.
       // We load the full node to check whether the user can edit it.
       $translation_node = node_load($translations[$language->language]->nid);
-      $title = l($translation_node->title, 'node/' . $translation_node->nid);
+      $title = entity_l($translation_node->title, 'node', $translation_node);
       if (node_access('update', $translation_node)) {
         $options[] = l(t('edit'), "node/$translation_node->nid/edit");
       }
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1165
diff -u -p -r1.1165 user.module
--- modules/user/user.module	1 May 2010 08:12:23 -0000	1.1165
+++ modules/user/user.module	4 May 2010 02:02:22 -0000
@@ -841,7 +841,7 @@ function user_search_execute($keys = NUL
     ->limit(15)
     ->execute();
   foreach ($result as $account) {
-    $find[] = array('title' => $account->name . ' (' . $account->mail . ')', 'link' => url('user/' . $account->uid, array('absolute' => TRUE)));
+    $find[] = array('title' => $account->name . ' (' . $account->mail . ')', 'link' => entity_url('user', $account, array('absolute' => TRUE)));
   }
   return $find;
 }
@@ -1342,8 +1342,8 @@ function template_preprocess_user_pictur
         $variables['user_picture'] = theme('image', array('path' => $filepath, 'alt' => $alt, 'title' => $alt, 'attributes' => array(), 'getsize' => FALSE));
       }
       if (!empty($account->uid) && user_access('access user profiles')) {
-        $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
-        $variables['user_picture'] = l($variables['user_picture'], "user/$account->uid", $attributes);
+        $options = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
+        $variables['user_picture'] = entity_l($variables['user_picture'], 'user', $account, $options);
       }
     }
   }
@@ -1822,7 +1822,8 @@ function user_login($form, &$form_state)
 
   // If we are already logged on, go to the user page instead.
   if ($user->uid) {
-    drupal_goto('user/' . $user->uid);
+    $uri = entity_uri('user', $user);
+    drupal_goto($uri['path'], $uri['options']);
   }
 
   // Display login form:
@@ -2030,7 +2031,7 @@ function user_login_finalize(&$edit = ar
 function user_login_submit($form, &$form_state) {
   global $user;
   $user = user_load($form_state['uid']);
-  $form_state['redirect'] = 'user/' . $user->uid;
+  $form_state['redirect'] = entity_uri('user', $user);
 
   user_login_finalize($form_state);
 }
@@ -3348,7 +3349,8 @@ function user_register_form($form, &$for
 
   // If we aren't admin but already logged on, go to the user page instead.
   if (!$admin && $user->uid) {
-    drupal_goto('user/' . $user->uid);
+    $uri = entity_uri('user', $user);
+    drupal_goto($uri['path'], $uri['options']);
   }
 
   $form['#user'] = drupal_anonymous_user();
@@ -3435,9 +3437,8 @@ function user_register_submit($form, &$f
   $account->password = $pass;
 
   // New administrative account without notification.
-  $uri = entity_uri('user', $account);
   if ($admin && !$notify) {
-    drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
+    drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => entity_url('user', $account), '%name' => $account->name)));
   }
   // No e-mail verification required; log in user immediately.
   elseif (!$admin && !variable_get('user_email_verification', TRUE) && $account->status) {
@@ -3452,7 +3453,7 @@ function user_register_submit($form, &$f
     $op = $notify ? 'register_admin_created' : 'register_no_approval_required';
     _user_mail_notify($op, $account);
     if ($notify) {
-      drupal_set_message(t('A welcome message with further instructions has been e-mailed to the new user <a href="@url">%name</a>.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
+      drupal_set_message(t('A welcome message with further instructions has been e-mailed to the new user <a href="@url">%name</a>.', array('@url' => entity_url('user', $account), '%name' => $account->name)));
     }
     else {
       drupal_set_message(t('A welcome message with further instructions has been sent to your e-mail address.'));
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.71
diff -u -p -r1.71 user.pages.inc
--- modules/user/user.pages.inc	1 May 2010 08:12:23 -0000	1.71
+++ modules/user/user.pages.inc	4 May 2010 02:02:22 -0000
@@ -391,9 +391,10 @@ function user_cancel_confirm_form($form,
 
   // Always provide entity id in the same form key as in the entity edit form.
   $form['uid'] = array('#type' => 'value', '#value' => $account->uid);
+  $uri = entity_uri('user', $account);
   return confirm_form($form,
     $question,
-    'user/' . $account->uid,
+    array('path' => $uri['path']) + $uri['options'],
     $description . ' ' . t('This action cannot be undone.'),
     t('Cancel account'), t('Cancel'));
 }
@@ -428,7 +429,7 @@ function user_cancel_confirm_form_submit
     drupal_set_message(t('A confirmation request to cancel your account has been sent to your e-mail address.'));
     watchdog('user', 'Sent account cancellation request to %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
 
-    $form_state['redirect'] = "user/$account->uid";
+    $form_state['redirect'] = entity_uri('user', $account);
   }
 }
 
Index: modules/user/user.tokens.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.tokens.inc,v
retrieving revision 1.6
diff -u -p -r1.6 user.tokens.inc
--- modules/user/user.tokens.inc	20 Apr 2010 09:48:06 -0000	1.6
+++ modules/user/user.tokens.inc	4 May 2010 02:02:22 -0000
@@ -94,7 +94,7 @@ function user_tokens($type, $tokens, arr
           break;
 
         case 'url':
-          $replacements[$original] = url("user/$account->uid", $url_options);
+          $replacements[$original] = entity_url('user', $account, $url_options);
           break;
 
         case 'edit-url':
