? Drupal_path_alias_alternate_by_goba.patch ? Drupal_path_reform.patch Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.66 diff -u -r1.66 bootstrap.inc --- includes/bootstrap.inc 8 Sep 2005 19:17:34 -0000 1.66 +++ includes/bootstrap.inc 15 Sep 2005 19:14:57 -0000 @@ -476,49 +476,55 @@ * @param $action * One of the following values: * - wipe: delete the alias cache. - * - source: indicates that given a Drupal system URL, return an alias if one exists. - * - alias: indicates that given an path alias, return the Drupal system URL if one exists. + * - alias: indicates that given a Drupal system URL, return an alias if one exists. + * - source: indicates that given an path alias, return the Drupal system URL if one exists. * @param $path * The path to investigate for corresponding aliases or system URLs. */ function drupal_lookup_path($action, $path = '') { static $map = array(); static $count = NULL; - + static $custom_rewrite = FALSE; if ($count === NULL) { $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}')); + $custom_rewrite = function_exists('custom_url_rewrite'); } - + if ($action == 'wipe') { $map = array(); + return TRUE; } - elseif ($count > 0 && $path != '') { - if ($action == 'source') { - if (isset($map[$path])) { - return $map[$path]; - } - if ($alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path))) { - $map[$path] = $alias; - return $alias; - } - else { - $map[$path] = $path; - } - } - elseif ($action == 'alias') { - if ($alias = array_search($path, $map)) { - return $alias; - } - if (!isset($map[$path])) { - if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) { - $map[$src] = $path; - return $src; - } - else { + + if ($path != '' && ($count || $custom_rewrite)) { + switch ($action) { + case 'alias': + if (!isset($map[$path])) { $map[$path] = $path; - } - } + if ($count && ($alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path)))) { + $map[$path] = $alias; + } + if ($custom_rewrite) { + $map[$path] = custom_url_rewrite('alias', $path, $map[$path]); + } + } + return $map[$path]; + break; + + case 'source': + if (!($source = array_search($path, $map))) { + if ($count) { + $source = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path));{ + } + if ($custom_rewrite) { + $source = custom_url_rewrite('source', $source, $path); + } + if ($source) { + $map[$source] = $path; + } + } + return $source; + break; } } @@ -526,22 +532,6 @@ } /** - * Given an internal Drupal path, return the alias set by the administrator. - */ -function drupal_get_path_alias($path) { - if ($alias = drupal_lookup_path('source', $path)) { - return $alias; - } - elseif (function_exists('conf_url_rewrite')) { - return conf_url_rewrite($path, 'outgoing'); - } - else { - // No alias found. Return the normal path. - return $path; - } -} - -/** * Get the title of the current page, for display on the page and in the title bar. */ function drupal_get_title() { @@ -678,10 +668,12 @@ * explanation in menu.inc for how to construct callbacks that take arguments. */ function arg($index) { - static $arguments, $q; + static $arguments = NULL; + static $q = NULL; - if (empty($arguments) || $q != $_GET['q']) { + if (!isset($arguments) || $q !== $_GET['q']) { $arguments = explode('/', $_GET['q']); + $q = $_GET['q']; } if (isset($arguments[$index])) { Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.476 diff -u -r1.476 common.inc --- includes/common.inc 31 Aug 2005 18:37:30 -0000 1.476 +++ includes/common.inc 15 Sep 2005 19:14:58 -0000 @@ -131,22 +131,6 @@ } /** - * Given a path alias, return the internal path it represents. - */ -function drupal_get_normal_path($path) { - //drupal_get_path_alias($path); - if ($src = drupal_lookup_path('alias', $path)) { - return $src; - } - elseif (function_exists('conf_url_rewrite')) { - return conf_url_rewrite($path, 'incoming'); - } - else { - return $path; - } -} - -/** * Set an HTTP response header for the current page. */ function drupal_set_header($header = NULL) { @@ -272,7 +256,7 @@ header('HTTP/1.0 404 Not Found'); watchdog('page not found', t('%page not found.', array('%page' => theme('placeholder', $_GET['q']))), WATCHDOG_WARNING); - $path = drupal_get_normal_path(variable_get('site_404', '')); + $path = drupal_lookup_path('source', variable_get('site_404', '')); $status = MENU_NOT_FOUND; if ($path) { menu_set_active_item($path); @@ -292,7 +276,7 @@ header('HTTP/1.0 403 Forbidden'); watchdog('access denied', t('%page denied access.', array('%page' => theme('placeholder', $_GET['q']))), WATCHDOG_WARNING, l(t('view'), $_GET['q'])); - $path = drupal_get_normal_path(variable_get('site_403', '')); + $path = drupal_lookup_path('source',variable_get('site_403', '')); $status = MENU_NOT_FOUND; if ($path) { menu_set_active_item($path); @@ -1586,7 +1570,7 @@ $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) ? 'index.php' : ''; } - $path = drupal_get_path_alias($path); + $path = drupal_lookup_path('alias', $path); if (isset($fragment)) { $fragment = '#'. $fragment; @@ -1923,10 +1907,10 @@ unicode_check(); // Initialize $_GET['q'] prior to loading modules and invoking hook_init(). if (!empty($_GET['q'])) { - $_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/')); + $_GET['q'] = drupal_lookup_path('source', trim($_GET['q'], '/')); } else { - $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node')); + $_GET['q'] = drupal_lookup_path('source', variable_get('site_frontpage', 'node')); } // Initialize all enabled modules. module_init(); Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.84 diff -u -r1.84 menu.inc --- includes/menu.inc 25 Aug 2005 21:14:16 -0000 1.84 +++ includes/menu.inc 15 Sep 2005 19:15:00 -0000 @@ -789,7 +789,7 @@ $result = db_query('SELECT * FROM {menu} ORDER BY mid ASC'); while ($item = db_fetch_object($result)) { // Handle URL aliases if entered in menu administration. - $item->path = drupal_get_normal_path($item->path); + $item->path = drupal_lookup_path('source', $item->path); if (array_key_exists($item->path, $_menu['path index'])) { // The path is already declared. $old_mid = $_menu['path index'][$item->path]; Index: modules/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block.module,v retrieving revision 1.180 diff -u -r1.180 block.module --- modules/block.module 14 Sep 2005 21:37:11 -0000 1.180 +++ modules/block.module 15 Sep 2005 19:15:00 -0000 @@ -493,7 +493,7 @@ // Match path if necessary if ($block->pages) { if ($block->visibility < 2) { - $path = drupal_get_path_alias($_GET['q']); + $path = drupal_lookup_path('alias', $_GET['q']); $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($block->pages, '/')) .')$/'; $page_match = !($block->visibility xor preg_match($regexp, $path)); } Index: modules/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path.module,v retrieving revision 1.62 diff -u -r1.62 path.module --- modules/path.module 25 Aug 2005 21:14:16 -0000 1.62 +++ modules/path.module 15 Sep 2005 19:15:00 -0000 @@ -216,7 +216,7 @@ case 'load': $path = "node/$node->nid"; - $alias = drupal_get_path_alias($path); + $alias = drupal_lookup_path('alias', $path); if ($alias != $path) { $node->path = $alias; } @@ -236,7 +236,7 @@ case 'delete': $path = "node/$node->nid"; - if (drupal_get_path_alias($path) != $path) { + if (drupal_lookup_path('alias', $path) != $path) { path_set_alias($path); } break; Index: modules/search.module =================================================================== RCS file: /cvs/drupal/drupal/modules/search.module,v retrieving revision 1.134 diff -u -r1.134 search.module --- modules/search.module 7 Sep 2005 20:57:39 -0000 1.134 +++ modules/search.module 15 Sep 2005 19:15:00 -0000 @@ -371,7 +371,7 @@ if ($tagname == 'a') { // Check if link points to a node on this site if (preg_match($node_regexp, $value, $match)) { - $path = drupal_get_normal_path($match[1]); + $path = drupal_lookup_path('source', $match[1]); if (preg_match('!(?:node|book)/(?:view/)?([0-9]+)!i', $path, $match)) { $linknid = $match[1]; if ($linknid > 0) { Index: themes/engines/phptemplate/phptemplate.engine =================================================================== RCS file: /cvs/drupal/drupal/themes/engines/phptemplate/phptemplate.engine,v retrieving revision 1.17 diff -u -r1.17 phptemplate.engine --- themes/engines/phptemplate/phptemplate.engine 9 Sep 2005 05:32:31 -0000 1.17 +++ themes/engines/phptemplate/phptemplate.engine 15 Sep 2005 19:15:01 -0000 @@ -111,7 +111,7 @@ // Tell all templates where they are located. $variables['directory'] = path_to_theme(); - if (drupal_get_path_alias($_GET['q']) == variable_get('site_frontpage', 'node')) { + if (drupal_lookup_path('alias', $_GET['q']) == variable_get('site_frontpage', 'node')) { $variables['is_front'] = true; }