? mw.patch
Index: path_redirect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/path_redirect/path_redirect.module,v
retrieving revision 1.3.2.30
diff -u -F^f -r1.3.2.30 path_redirect.module
--- path_redirect.module	8 Mar 2008 02:09:53 -0000	1.3.2.30
+++ path_redirect.module	2 May 2008 03:19:21 -0000
@@ -22,12 +22,10 @@ function path_redirect_help($path) {
 }
 
 /**
- * Implementation of hook_init
- *
  * Early checking of URL requested.
  * If a match is found, user is redirected using drupal_goto()
  */
-function path_redirect_init() {
+function path_redirect_redirect() {
   // see if this page has a redirect path
   $path = substr(request_uri(), strlen($GLOBALS['base_path']));
   if (preg_match('/^\?q=/', $path)) {
@@ -43,16 +41,10 @@ function path_redirect_init() {
   if ($r && !(variable_get('path_redirect_allow_bypass', 0) && !empty($_GET['redirect']) && $_GET['redirect'] == 'no') && url($r->redirect) != url($path)) {
     if (variable_get('path_redirect_redirect_warning', 0)) {
       drupal_set_message(t('This page has been moved. You may want to update your bookmarks.'));
-    }
-    if (function_exists('drupal_goto')) {
-      // if there's a result found, do the redirect
-      unset($_REQUEST['destination']);
-      drupal_goto($r->redirect, ($r->query ? $r->query: NULL), ($r->fragment ? $r->fragment : NULL), $r->type);
-    }
-    else {
-      // page caching is turned on so drupal_goto() (common.inc) hasn't been loaded
-      path_redirect_goto($r->redirect, ($r->query ? $r->query: NULL), ($r->fragment ? $r->fragment : NULL), $r->type);
-    }
+    }  
+    // if there's a result found, do the redirect
+    unset($_REQUEST['destination']);
+    drupal_goto($r->redirect, ($r->query ? $r->query: NULL), ($r->fragment ? $r->fragment : NULL), $r->type);
   }
   else if ($r && url($r->redirect) == url($path)) {
     watchdog('path_redirect', t('Redirect to <code>%redirect</code> is causing an infinite loop; redirect cancelled.', array('%redirect' => $r->redirect)), WATCHDOG_WARNING, l(t('edit'), 'admin/build/path-redirect/edit/'. $r->rid));
@@ -120,6 +112,9 @@ function path_redirect_menu($may_cache) 
       'access' => $access,
     );
   }
+  else {
+    path_redirect_redirect();
+  }
   return $items;
 }
 
@@ -439,40 +434,6 @@ function path_redirect_settings() {
 }
 
 /**
- * This is a copy of drupal_goto() redesigned for use during the bootstrap
- */
-function path_redirect_goto($path = '', $query = NULL, $fragment = NULL, $http_response_code = 302) {
-
-  $url = $path;
-
-  // Make the given path or URL absolute
-  if (!preg_match('/^[a-z]+:\/\//', $url)) {
-    global $base_url;
-    $url = $base_url .'/'. $url;
-  }
-
-  $url .= (empty($query)    ? '' : '?'. $query);
-  $url .= (empty($fragment) ? '' : '#'. $fragment);
-
-  // Remove newlines from the URL to avoid header injection attacks.
-  $url = str_replace(array("\n", "\r"), '', $url);
-
-  // Before the redirect, allow modules to react to the end of the page request.
-  bootstrap_invoke_all('exit');
-
-  // Even though session_write_close() is registered as a shutdown function, we
-  // need all session data written to the database before redirecting.
-  session_write_close();
-
-  header('Location: '. $url, TRUE, $http_response_code);
-
-  // The "Location" header sends a REDIRECT status code to the http
-  // daemon. In some cases this can go wrong, so we make sure none
-  // of the code below the drupal_goto() call gets executed when we redirect.
-  exit();
-}
-
-/**
  * Return an array of 300-range status codes
  * placed here for clarity
  */
