Index: includes/path.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/path.inc,v retrieving revision 1.36 diff -u -p -r1.36 path.inc --- includes/path.inc 16 May 2009 19:07:02 -0000 1.36 +++ includes/path.inc 18 May 2009 23:09:35 -0000 @@ -50,6 +50,7 @@ function drupal_lookup_path($action, $pa $no_src = &drupal_static(__FUNCTION__ . ':no_src', array()); $count = &drupal_static(__FUNCTION__ . ':count'); $system_paths = &drupal_static(__FUNCTION__ . ':system_paths'); + $whitelist = &drupal_static(__FUNCTION__ . ':whitelist'); $no_aliases = &drupal_static(__FUNCTION__ . ':no_alias', array()); $first_call = &drupal_static(__FUNCTION__ . ':first_call', TRUE); @@ -70,9 +71,11 @@ function drupal_lookup_path($action, $pa elseif ($count > 0 && $path != '') { if ($action == 'alias') { // During the first call to drupal_lookup_path() per language, load the - // expected system paths for the page from cache. + // expected system paths for the page from cache and fetch the path + // whitelist variable. if ($first_call) { $first_call = FALSE; + $whitelist = variable_get('path_optimization_list', drupal_path_whitelist()); $map[$path_language] = array(); // Load system paths from cache. $cid = current_path(); @@ -93,9 +96,13 @@ function drupal_lookup_path($action, $pa if (isset($map[$path_language][$path])) { return $map[$path_language][$path]; } + // If the alias is in the whitelist, return FALSE. + if (!drupal_match_path($path, $whitelist)) { + return FALSE; + } // 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 + 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( ':src' => $path, ':language' => $path_language @@ -347,3 +354,19 @@ function drupal_match_path($path, $patte function current_path() { return $_GET['q']; } + +/** + * Helper function for drupal_lookup_path(). + * + * @return + * A list of system paths to be used as the default whitelist for + * drupal_lookup_path(). Aliases will only be saved or looked up for system + * paths matching this list. + * + */ +function drupal_path_whitelist() { + return 'node* + user* + taxonomy/term/*'; +} + Index: modules/path/path.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.admin.inc,v retrieving revision 1.21 diff -u -p -r1.21 path.admin.inc --- modules/path/path.admin.inc 16 May 2009 15:23:16 -0000 1.21 +++ modules/path/path.admin.inc 18 May 2009 23:09:37 -0000 @@ -140,6 +140,13 @@ function path_admin_form_validate($form, $src = $form_state['values']['src']; $dst = $form_state['values']['dst']; $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0; + $whitelist = variable_get('path_optimization_list', drupal_path_whitelist()); + + if (!drupal_match_path($src, $whitelist)) { + // @TODO Offer a pointer on how to correct this. + form_set_error('src', t("The path '@link_path' cannot be aliased because it is skipped by default when querying path aliases.", array('@link_path' => $src))); + } + // Language is only set if locale module is enabled, otherwise save for all languages. $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : ''; Index: sites/default/default.settings.php =================================================================== RCS file: /cvs/drupal/drupal/sites/default/default.settings.php,v retrieving revision 1.24 diff -u -p -r1.24 default.settings.php --- sites/default/default.settings.php 24 Apr 2009 08:16:56 -0000 1.24 +++ sites/default/default.settings.php 18 May 2009 23:09:37 -0000 @@ -330,3 +330,16 @@ $conf = array( # $conf['blocked_ips'] = array( # 'a.b.c.d', # ); + +/** + * drupal_lookup_path() whitelist. + * + * By default, drupal_lookup_path() only queries path aliases for the paths + * defined by drupal_path_blacklist(). If you need to override this list, either + * to add or remove paths, you should uncomment the following lines to define + * your own string of paths to ignore. An empty value will result in all paths being + * queried and may incur a performance penalty + */ +# $conf['path_optimizaton_list'] = 'node* +# user* +# taxonomy/term/*'; ? sites/all/modules/pqp/d7.patch