diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-06-02 15:06:09 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-06-02 15:06:09 +0000 |
commit | 34c996e28cea7729ed07d1bec33f51ccca21e607 (patch) | |
tree | 011ebfca6cd25a38b7d59e961d92f102ccf6ded0 | |
parent | 4f2e13f50376a9032f8157563aeb6eede34433eb (diff) | |
download | brdo-34c996e28cea7729ed07d1bec33f51ccca21e607.tar.gz brdo-34c996e28cea7729ed07d1bec33f51ccca21e607.tar.bz2 |
- Patch #358315 by neochief et al: drupal_lookup_path() not respects alias' order.
-rw-r--r-- | includes/path.inc | 6 | ||||
-rw-r--r-- | modules/system/system.install | 16 |
2 files changed, 17 insertions, 5 deletions
diff --git a/includes/path.inc b/includes/path.inc index fa066aac3..ac08ac4c2 100644 --- a/includes/path.inc +++ b/includes/path.inc @@ -87,7 +87,7 @@ function drupal_lookup_path($action, $path = '', $path_language = '') { // Now fetch the aliases corresponding to these system paths. // We order by ASC and overwrite array keys to ensure the correct // alias is used when there are multiple aliases per path. - $map[$path_language] = db_query("SELECT src, dst FROM {url_alias} WHERE src IN(:system) AND language IN(:language, '') ORDER BY language ASC", array( + $map[$path_language] = db_query("SELECT src, dst FROM {url_alias} WHERE src IN(:system) AND language IN(:language, '') ORDER BY language ASC, pid ASC", array( ':system' => $system_paths, ':language' => $path_language ))->fetchAllKeyed(); @@ -108,7 +108,7 @@ function drupal_lookup_path($action, $path = '', $path_language = '') { // For system paths which were not cached, query aliases individually. else if (!isset($no_aliases[$path_language][$path])) { // Get the most fitting result falling back with alias without language - $alias = db_query("SELECT dst FROM {url_alias} WHERE src = :src AND language IN(:language, '') ORDER BY language DESC", array( + $alias = db_query("SELECT dst FROM {url_alias} WHERE src = :src AND language IN(:language, '') ORDER BY language DESC, pid DESC", array( ':src' => $path, ':language' => $path_language ))->fetchField(); @@ -123,7 +123,7 @@ function drupal_lookup_path($action, $path = '', $path_language = '') { $src = ''; if (!isset($map[$path_language]) || !($src = array_search($path, $map[$path_language]))) { // Get the most fitting result falling back with alias without language - if ($src = db_query("SELECT src FROM {url_alias} WHERE dst = :dst AND language IN(:language, '') ORDER BY language DESC", array( + if ($src = db_query("SELECT src FROM {url_alias} WHERE dst = :dst AND language IN(:language, '') ORDER BY language DESC, pid DESC", array( ':dst' => $path, ':language' => $path_language)) ->fetchField()) { diff --git a/modules/system/system.install b/modules/system/system.install index 1f535c586..1fe22718a 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -1340,11 +1340,11 @@ function system_schema() { ), ), 'unique keys' => array( - 'dst_language' => array('dst', 'language'), + 'dst_language_pid' => array('dst', 'language', 'pid'), ), 'primary key' => array('pid'), 'indexes' => array( - 'src_language' => array('src', 'language'), + 'src_language_pid' => array('src', 'language', 'pid'), ), ); @@ -3525,6 +3525,18 @@ function system_update_7024() { return $ret; } + /** + * Improve indexes on the {url_alias} table. + */ +function system_update_7025() { + $ret = array(); + db_drop_index($ret, 'url_alias', 'src_language'); + db_drop_index($ret, 'url_alias', 'dst_language'); + db_add_index($ret, 'url_alias', 'dst_language_pid', array('dst', 'language', 'pid')); + db_add_index($ret, 'url_alias', 'src_language_pid', array('src', 'language', 'pid')); + return $ret; +} + /** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. |