Index: me.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/me/me.module,v
retrieving revision 1.3.4.4
diff -u -r1.3.4.4 me.module
--- me.module	2 Mar 2009 22:20:34 -0000	1.3.4.4
+++ me.module	31 Mar 2009 02:28:36 -0000
@@ -5,7 +5,7 @@
  * Implementation of hook_menu().
  */
 function me_menu($may_cache) {
-  $items=array();
+  $items = array();
 
   if ($may_cache) {
     $items[] = array(
@@ -18,26 +18,40 @@
       'type' => MENU_NORMAL_ITEM, // optional
     );
   }
-  else {
-    // We need to check the current path to see if it matches any of our aliases.
-    // We only need to check that it matches the beginning of the alias.
-    // For this to work properly, 'me' also needs to be the last module to run it's
-    // hook_menu().
-
-    $aliases = explode("\n",variable_get('me_aliases','user/me'));
-    foreach ($aliases as $alias) {
-      // check to see if there's a 'me' to replace;
-      // either '.../me/...', 'me/...' or '.../me' but eg 'readme/...' does not count
-      $alias = preg_split('/[\?\#]/', $alias);
-      $alias = trim(check_url($alias[0]), "/ \t\n\r\0");
-      $path = drupal_get_normal_path($_GET['q']);
-      if (preg_match('/(\/m|^m)(e$|e\/)/', $alias, $matches) > 0 && 0 === strpos($path, $alias)) {
-        $items[] = array(
-          'path' => $path,
-          'type' => MENU_CALLBACK,
-          'callback' => 'me_relay',
-          'access' => true, // we're handing over access control to the destiation page
-        );
+
+  // If users have static paths for 'me' in the menu, then we need to be able to handle those correctly.
+  // This is handled when $may_cache is TRUE.
+
+  // When $may_cache is FALSE, then we need to check the current path to see
+  //i f it matches any of our aliases. We only need to check that it matches
+  // the beginning of the alias. For this to work properly, 'me' also needs
+  // to be the last module to run it's hook_menu().
+
+  return array_merge($items, _me_create_menu_items($may_cache));
+}
+
+/**
+ * Helper function to create our menu items.
+ */
+function _me_create_menu_items($may_cache) {
+  $items = array();
+
+  $aliases = explode("\n",variable_get('me_aliases','user/me'));
+  foreach ($aliases as $alias) {
+    // check to see if there's a 'me' to replace;
+    // either '.../me/...', 'me/...' or '.../me' but eg 'readme/...' does not count
+    $alias = preg_split('/[\?\#]/', $alias);
+    $alias = trim(check_url($alias[0]), "/ \t\n\r\0");
+    $path = drupal_get_normal_path($_GET['q']);
+    if (preg_match('/(\/m|^m)(e$|e\/)/', $alias, $matches) > 0 && ($may_cache || 0 === strpos($path, $alias))) {
+      $items[] = array(
+        'path' => $may_cache ? $alias : $path,
+        'type' => MENU_CALLBACK,
+        'callback' => 'me_relay',
+        'access' => true, // we're handing over access control to the destiation page
+      );
+
+      if (!$may_cache) {
         break;
       }
     }
