path_redirect.module
string 39 - 42

  if (!$r) {
    $path = preg_replace('/\?.*/', '', $path);
    $r = db_fetch_object(db_query("SELECT rid, redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $path, urlencode(utf8_encode($path))));
  }

Should be:

  if (!$r) {
    $path_2 = preg_replace('/\?.*/', '', $path);
    if($path_2 != $path) {
      $r = db_fetch_object(db_query("SELECT rid, redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $path_2, urlencode(utf8_encode($path_2))));
    }
  }

Every page witch has no redirect hits database two times.
This fix it.

Comments

dave reid’s picture

Status: Active » Closed (duplicate)

Duplicate of the path check rewrite I'm working on in #368377: Rewrite path matching code.