2

I have a Drupal 7 site and have a bunch of custom modules installed. Currently when I hit a specific node/9283 it gets redirected to another page. I'm not sure which module is causing this redirect. I also check URL Alias and nothing is there for redirection. Its definitely something custom. How would you go about debugging this and figuring out which module/code/function is being loaded on this redirect to another page on the same site?

4
  • What kind of redirect is it? HTTP status code? Which one? Or JS? Or meta http-equiv? Or something else? And you have php module turned off, right? – Mołot Oct 13 '15 at 21:08
  • im not sure how you would find the http status code. i turned off JS and it still redirects. so something on the backend is firing. – Patoshi パトシ Oct 13 '15 at 21:13
  • Use browser's console, network card? F12 in Chrome, for example? I don't want to sound mean, but that's kinda basic thing when developing and debugging interactions between server and client side. – Mołot Oct 13 '15 at 21:15
  • oh yes.. thats true. i haven't used that tool in awhile. thanks for pointing that out. – Patoshi パトシ Oct 13 '15 at 21:16
3

If we're talking Drupal redirects (i.e. drupal_goto calls), the Devel module could help out here. In its settings it has a Display redirection page option that halts redirection for inspection.

You can use this in conjunction with a hook_drupal_goto_alter() invocation to dump a stack trace on the redirection halt page to find the origin of the drupal_goto call.

function MYMODULE_drupal_goto_alter(&$path, &$options, &$http_response_code) {
  ddebug_backtrace();
}
0

What I do is:

  1. Clone site do dev environment

  2. Xdebug

  3. Step by step execution

Simple, once you get your development environment up and running.

3
  • all these years. i have never setup xdebug before. i can't really clone the site that easily as its 30gb+... -_- .. i am working remotely off of the dev server. aside from xdebug how else would you debug this? – Patoshi パトシ Oct 13 '15 at 21:04
  • @duckx I usually omit media files when cloning - then 30GB shrinks to mere dozens of megabytes, usually. Aside from xdebug? I would try not to. Like, at all. Either it's my site and I know what I changed, or it's inherited and if it's owner does not want to provide infrastructure with dev environment, I don't want to work for him. But see my comment under your question. – Mołot Oct 13 '15 at 21:08
  • i remember there was a way to do some type of back trace function finding thing by adding a function call in the index.php .. forgot how that was done. it was a long time ago. – Patoshi パトシ Oct 13 '15 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.