Index: includes/path.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/path.inc,v retrieving revision 1.65 diff -u -p -r1.65 path.inc --- includes/path.inc 16 Jul 2010 02:51:44 -0000 1.65 +++ includes/path.inc 17 Jul 2010 23:49:08 -0000 @@ -127,6 +127,7 @@ function drupal_lookup_path($action, $pa // isn't a path that has this alias elseif ($action == 'source' && !isset($cache['no_source'][$path_language][$path])) { // Look for the value $path within the cached $map + $source = FALSE; if (!isset($cache['map'][$path_language]) || !($source = array_search($path, $cache['map'][$path_language]))) { // Get the most fitting result falling back with alias without language if ($source = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", array( @@ -135,7 +136,6 @@ function drupal_lookup_path($action, $pa ':language_none' => LANGUAGE_NONE)) ->fetchField()) { $cache['map'][$path_language][$source] = $path; - return $source; } else { // We can't record anything into $map because we do not have a valid @@ -144,6 +144,7 @@ function drupal_lookup_path($action, $pa $cache['no_source'][$path_language][$path] = TRUE; } } + return $source; } } Index: modules/path/path.test =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.test,v retrieving revision 1.35 diff -u -p -r1.35 path.test --- modules/path/path.test 26 Mar 2010 12:37:30 -0000 1.35 +++ modules/path/path.test 17 Jul 2010 23:49:08 -0000 @@ -277,7 +277,7 @@ class PathLanguageTestCase extends Drupa // Confirm that the alias works. $this->drupalGet($edit['path[alias]']); - $this->assertText($english_node->title, 'Alias works.'); + $this->assertText($english_node->title, t('Alias works.')); // Translate the node into French. $this->drupalGet('node/' . $english_node->nid . '/translate'); @@ -295,17 +295,21 @@ class PathLanguageTestCase extends Drupa // Ensure the node was created. $french_node = $this->drupalGetNodeByTitle($edit["title"]); - $this->assertTrue(($french_node), 'Node found in database.'); + $this->assertTrue(($french_node), t('Node found in database.')); // Confirm that the alias works. $this->drupalGet('fr/' . $edit['path[alias]']); - $this->assertText($french_node->title, 'Alias for French translation works.'); + $this->assertText($french_node->title, t('Alias for French translation works.')); // Confirm that the alias is returned by url(). drupal_static_reset('language_list'); $languages = language_list(); $url = url('node/' . $french_node->nid, array('language' => $languages[$french_node->language])); $this->assertTrue(strpos($url, $edit['path[alias]']), t('URL contains the path alias.')); + + // Check that source for alias returns from cache. + $french_node_path = drupal_lookup_path('source', $edit['path[alias]'], $french_node->language); + $this->assertEqual($french_node_path, 'node/' . $french_node->nid, t('Normal path is the same.')); } }