? .DS_Store
? optimize_drupal_lookup_patch2.patch
Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.13
diff -u -p -r1.13 path.inc
--- includes/path.inc	23 Dec 2006 22:04:52 -0000	1.13
+++ includes/path.inc	3 Jan 2007 12:09:24 -0000
@@ -58,7 +58,12 @@ function drupal_lookup_path($action, $pa
       if (isset($map[$path])) {
         return $map[$path];
       }
-      $alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path));
+      if (_drupal_matches_skiplist($path)) {
+        $alias = FALSE;
+      }
+      elseif (!$alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path))) {
+        $alias = FALSE;
+      }
       $map[$path] = $alias;
       return $alias;
     }
@@ -67,7 +72,10 @@ function drupal_lookup_path($action, $pa
     elseif ($action == 'source' && !isset($no_src[$path])) {
       // Look for the value $path within the cached $map
       if (!$src = array_search($path, $map)) {
-        if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
+          if (_drupal_matches_skiplist($path)) {
+            $map[$src] = $path;
+          }
+          elseif ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
           $map[$src] = $path;
         }
         else {
@@ -205,3 +213,28 @@ function drupal_is_front_page() {
   // we can check it against the 'site_frontpage' variable.
   return $_GET['q'] == drupal_get_normal_path(variable_get('site_frontpage', 'node'));
 }
+
+/**
+ * Check if a path matches a path in the skiplist.
+ *
+ * @param $path
+ *   The path to test.
+ *
+ * @return
+ *   Boolean value: TRUE if the path matches a path in the skiplist, FALSE if otherwise.
+ */
+function _drupal_matches_skiplist($path) {
+  static $skiplist;
+
+  // Use $skiplist to avoid retrieving the skiplist every time in subsequent calls
+  if (!isset($skiplist)) {
+    $skiplist = variable_get('path_skiplist', array());
+  }
+
+  $path_match = 0;
+  for ($i = 0; !$path_match && $i < count($skiplist); $i++) {
+    $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($skiplist[$i], '/')) .')$/';
+    $path_match = preg_match($regexp, $path);
+  }
+  return $path_match > 0;
+}
\ No newline at end of file
Index: modules/path/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.module,v
retrieving revision 1.104
diff -u -p -r1.104 path.module
--- modules/path/path.module	18 Dec 2006 11:16:51 -0000	1.104
+++ modules/path/path.module	3 Jan 2007 12:09:25 -0000
@@ -122,6 +122,43 @@ function path_admin_delete($pid = 0) {
   drupal_set_message(t('The alias has been deleted.'));
 }
 
+/**
+ * Menu callback; presents the skiplist form.
+ */
+function path_admin_skiplist() {
+  $skiplist = variable_get(
+    'path_skiplist',
+    array('*/add', '*/edit', '*/load', '*/outline', '*/render', '*/revisions', '*/track', '*/votes', 'admin', 'admin/*', 'aggregator', 'aggregator/*', 'book', 'comment/*', 'devel', 'devel/*', 'filter', 'filter/*', 'lm_paypal', 'lm_paypal/*', 'logout', 'node', 'poll', 'profile', 'tracker', 'tracker/*', 'user')
+  );
+  $skiplist_flat = implode("\n", $skiplist);
+
+  $form = array();
+  $form['skiplist'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Skiplist'),
+    '#default_value' => $skiplist_flat,
+    '#rows' => 40,
+    '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page."),
+  );
+  $form['submit'] = array('#type' => 'submit', '#value' => t('Save skiplist'));
+  $form['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults'));
+  return $form;
+}
+
+/**
+ * Save the updated skiplist.
+ **/
+function path_admin_skiplist_submit($form_id, $form_values) {
+  if ($form_values['op'] == t('Save skiplist')) {
+    variable_set('path_skiplist', explode("\n", $form_values['skiplist']));
+    drupal_set_message(t('The skiplist has been saved.'));
+  }
+  elseif ($form_values['op'] == t('Reset to defaults')) {
+    variable_del('path_skiplist');
+    drupal_set_message(t('The skiplist has been reset.'));
+  }
+}
+
 
 
 /**
