? patches
? pathauto.api.php
Index: pathauto.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pathauto/pathauto.inc,v
retrieving revision 1.56.2.20
diff -u -p -r1.56.2.20 pathauto.inc
--- pathauto.inc	24 Jul 2010 21:30:52 -0000	1.56.2.20
+++ pathauto.inc	26 Jul 2010 23:25:50 -0000
@@ -133,7 +133,8 @@ define('PATHAUTO_PREG_CLASS_UNICODE_WORD
  *   TRUE if an alias exists, FALSE if not.
  */
 function _pathauto_alias_exists($alias, $source, $language = '') {
-  $alias_pid = db_result(db_query_range("SELECT pid FROM {url_alias} WHERE dst = '%s' AND src <> '%s' AND language = '%s'", array($alias, $source, $language), 0, 1));
+  $pid = db_result(db_query_range("SELECT pid FROM {url_alias} WHERE src <> '%s' AND dst = '%s' AND language IN ('%s', '') ORDER BY language DESC, pid DESC", $source, $alias, $language, 0, 1));
+
   if (module_exists('path_redirect') && function_exists('path_redirect_delete_multiple')) {
     // Delete from path_redirect the exact same alias to the same node.
     path_redirect_delete_multiple(NULL, array('source' => $alias, 'redirect' => $source));
@@ -141,7 +142,8 @@ function _pathauto_alias_exists($alias, 
     // If there still is this alias used in path_redirect, then create a different alias.
     $redirects = path_redirect_load_multiple(NULL, array('source' => $alias));
   }
-  if ($alias_pid || !empty($redirects)) {
+
+  if ($pid || !empty($redirects)) {
     return TRUE;
   }
   else {
Index: pathauto.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pathauto/pathauto.test,v
retrieving revision 1.1.4.19
diff -u -p -r1.1.4.19 pathauto.test
--- pathauto.test	26 Jul 2010 21:13:11 -0000	1.1.4.19
+++ pathauto.test	26 Jul 2010 23:25:53 -0000
@@ -598,12 +598,16 @@ class PathautoLocaleTestCase extends Pat
     // it is the newer alias.
     $this->saveEntityAlias('node', $node, 'french-node', 'fr');
 
+    // Add an alias with the soon-to-be generated alias, causing the upcoming
+    // alias update to generate a unique alias with the '-0' suffix.
+    $this->saveAlias('node/invalid', 'content/english-node', '');
+
     // Update the node, triggering a change in the English alias.
     pathauto_node_update_alias($node, 'update');
 
     // Check that the new English alias replaced the old one.
-    $this->assertEntityAlias('node', $node, 'content/english-node', 'en');
+    $this->assertEntityAlias('node', $node, 'content/english-node-0', 'en');
     $this->assertEntityAlias('node', $node, 'french-node', 'fr');
-    $this->assertAliasExists(array('pid' => $english_alias['pid'], 'alias' => 'content/english-node'));
+    $this->assertAliasExists(array('pid' => $english_alias['pid'], 'alias' => 'content/english-node-0'));
   }
 }
