At http://driverpacks.net, virtually all watchdog entries are generated by path_redirect. That's not very useful. At least not for me. (The reason for that insane amount of redirects is that there's >5 years of historical linking from other sites to that site, thus the relative redirect usage is very high.)

It's only a couple of lines of code and a very sensible, small feature — IMHO at least.

Let me know what you think :)

CommentFileSizeAuthor
#4 973700-4.patch1000 byteswim leers

Comments

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

The module should only be generating entries when it needs to (cases of infinite loops, etc). Could you at least provide more information about what watchdog messages you're seeing?

wim leers’s picture

Title: Add setting to disable watchdog logging » Make redirects case sensitive to avoid infinite redirects
Status: Postponed (maintainer needs more info) » Active

Now that you mention it, they're indeed all for infinite redirect loops!

In my case, I'm redirecting from the old-style URL http://driverpacks.net/DriverPacks to http://driverpacks.net/driverpacks. It seems Path Redirect considers the "from" path in a case insensitive manner, which then causes this problem.

I'm not sure I'm in a position to suggest how to deal with this — I think I'll just await your point of view on this :)

dave reid’s picture

That's because Drupal treats both mixed and lower case the same. The best solution is to add a lower-case condition to your htaccess file.

wim leers’s picture

Title: Make redirects case sensitive to avoid infinite redirects » Make redirects case sensitive
Status: Active » Needs review
StatusFileSize
new1000 bytes

Aha!
After all those years in Drupal, I had no idea about that.

But *where* does this happen then? I see this in the code:

    if (url($redirect['redirect']) == url($_GET['q'])) {
      // Prevent infinite loop redirection.
      watchdog('path_redirect', 'Redirect to <c ode>%redirect</c ode> is causing an infinite loop; redirect cancelled.', array('%redirect' => $redirect['redirect_url']), WATCHDOG_WARNING, l(t('Edit'), 'admin/build/path-redirect/edit/'. $redirect['rid']));
    }

Now, if I try the following:

  dvr(url("driverpacks"));
  dvr(url("DriverPacks"));

Then Drupal doesn't treat them as the same. I believed you when you claimed it was Drupal to blame, but it turns out it's not! :) (This is what I get for writing the issue follow-up while working things out.)

Rather, it seems it does a redirect once (from "/DriverPacks" to "/driverpacks") and then it checks if it is still equal. But I had missed something: why was it checking for a redirect anyway? It's your query in path_redirect_load_by_source() that should prevent case-insensitive matches!

Patch attached. You may want to make this an option though. This supersedes #617366: Add an option for case-insensitive redirects and makes that one into a duplicate.

wim leers’s picture

I didn't see #617366: Add an option for case-insensitive redirects's patch before. It's a more comprehensive solution and might therefore be better. I'll leave it up to you, the module maintainer, to decide what to do, hence not yet marking this as duplicate, but feel free to do so.

dave reid’s picture

Status: Needs review » Closed (won't fix)

This type of redirect is probably better suited for Global redirect, not Path redirect. I've added code to prevent people from creating this type of redirect now.