Search code examples
debugginghttp-redirectkohana

Find what causes a re-direct when a button is clicked


Is there a way of finding what is causing a re-direct when a particular link is clicked. I have a kohana site with thousands of files and it would be near impossible to find where the code that makes the re-direct. The link is: http://www.loosediamonds.diamgs.com/shoppingbag and the redirect happens when the "checkout" button is clicked.

I have seen the link in the source code and it explicitly points to http://www.loosediamonds.diamgs.com/checkout/signin so there must be something that causes the jump to http://diamgs.com/

I'm hoping there is a bit of software that can trace anything linked to that button click.


Solution

  • Redirect is performed by Konana by:

    1. Calling HTTP::redirect()
    2. Throwing corresponding redirect HTTP_Exception_ (By default HTTP_Exception_302)
    3. Redirecting within HTTP_Exception_Redirect::location() method.

    So to check where has redirect appeared I'd set Kohana::$environment to DEVELOPMENT, redifine HTTP_Exception_Redirect::location() method, interrupting it just before actual issuing Location header and use parent::get_response(); method to display nice default Kohana Exception page. This page should include Exception stack trace in which you'll see where does redirect was called.