From a7aab03a1e700c284e6e14e2dfa23f0b1f61a1d5 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Mon, 9 Feb 2009 16:27:35 +0000
Subject: [PATCH] - Patch #298722 by pwolanin: _menu_translate returns FALSE
 before to_arg is available.  Drupal.org upgrade blocker.

---
 includes/menu.inc            | 13 ++++++++-----
 modules/tracker/tracker.test |  1 +
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/includes/menu.inc b/includes/menu.inc
index c16e6cde15c9..816b535efe9d 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -589,7 +589,7 @@ function _menu_item_localize(&$item, $map, $link_translate = FALSE) {
  *
  * Translation of menu item titles and descriptions are done here to
  * allow for storage of English strings in the database, and translation
- * to the language required to generate the current page
+ * to the language required to generate the current page.
  *
  * @param $router_item
  *   A menu router item
@@ -600,21 +600,24 @@ function _menu_item_localize(&$item, $map, $link_translate = FALSE) {
  *   path from the menu table, for example tabs.
  * @return
  *   Returns the map with objects loaded as defined in the
- *   $item['load_functions. $item['access'] becomes TRUE if the item is
+ *   $item['load_functions']. $item['access'] becomes TRUE if the item is
  *   accessible, FALSE otherwise. $item['href'] is set according to the map.
  *   If an error occurs during calling the load_functions (like trying to load
  *   a non existing node) then this function return FALSE.
  */
 function _menu_translate(&$router_item, $map, $to_arg = FALSE) {
+  if ($to_arg) {
+    // Fill in missing path elements, such as the current uid.
+    _menu_link_map_translate($map, $router_item['to_arg_functions']);
+  }
+  // The $path_map saves the pieces of the path as strings, while elements in
+  // $map may be replaced with loaded objects.
   $path_map = $map;
   if (!_menu_load_objects($router_item, $map)) {
     // An error occurred loading an object.
     $router_item['access'] = FALSE;
     return FALSE;
   }
-  if ($to_arg) {
-    _menu_link_map_translate($path_map, $router_item['to_arg_functions']);
-  }
 
   // Generate the link path for the page request or local tasks.
   $link_map = explode('/', $router_item['path']);
diff --git a/modules/tracker/tracker.test b/modules/tracker/tracker.test
index e696d24a82d6..ba917fa80e3e 100644
--- a/modules/tracker/tracker.test
+++ b/modules/tracker/tracker.test
@@ -42,6 +42,7 @@ class TrackerTest extends DrupalWebTestCase {
     $this->drupalGet('tracker');
     $this->assertText($page1['title'], t('Nodes show up in the tracker listing.'));
     $this->assertNoText($page2['title'], t('Unpublished nodes do not show up in the tracker listing.'));
+    $this->assertLink(t('My recent posts'), 0, t('User tab shows up on the global tracker page.'));
   }
 
   /**
-- 
GitLab