1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

As Designed controller_pre_dispatch can run more than once

Discussion in 'Resolved Bug Reports' started by digitalpoint, Oct 18, 2013.

  1. digitalpoint

    digitalpoint Well-Known Member

    This very well might be by design, but I believe the behavior changed in 1.2 (fairly certain it didn't do it in 1.1)...

    If you end up rerouting a controller, both the beginning and destination controller trigger the controller_pre_dispatch event listeners.

    Realized this was happening now because I have something that happens within that event, but only on the 2nd page view. On the main forum page it would never happen because the first page view run controller_pre_dispatch twice (rerouting Index to Forum internally).

    Maybe it's by design... but just in case it's not, here's the report. I worked around it by only allowing the my code to run once per request.
  2. Mike

    Mike XenForo Developer Staff Member

    This is by design and as far as I know, this has happened since day 1.

    Pre-dispatch is called before any action is called (by the front controller). When you return a reroute back to the front controller, it goes through the whole dispatch loop again.

Share This Page