Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
perform check problem
  • hi guys im tripping about this bug maybe its just me but let me explain i have a simple setup: i have a auth driver in a package very similar to the simpleuser for the controllers i have a common controller that extends Controller_Template <code>
    class Controller_Common extends \Controller_Template { public function before($data = null)
    {
    \Log::debug('common');
    $logged_in = false;
    if(\Auth::check() === true)
    {
    $logged_in = true;
    }
    else
    {
    \Response::redirect('auth/login');
    }
    parent::before();
    } }
    </code> Now on the main controller i have this very simple method <code>
    class Controller_Dashboard extends Controller_Common { public function action_index()
    {
    \Log::debug('Dashboard/index');
    $this->template->title = "Dashboard";
    $this->template->content = View::factory('dashboard/index');
    } }
    </code> Ok lets see the problem. i have another log::debug("CHECK"); on the \Auth::check() (perform_check) method assuming i logged in successfully when i request dashboard/index i get this log: Debug - 2011-07-19 18:44:47 --> common
    Debug - 2011-07-19 18:44:47 --> CHECK
    Debug - 2011-07-19 18:44:47 --> Dashboard/index
    Debug - 2011-07-19 18:44:47 --> common
    Debug - 2011-07-19 18:44:47 --> common
    Debug - 2011-07-19 18:44:47 --> CHECK
    Debug - 2011-07-19 18:44:47 --> CHECK
    Debug - 2011-07-19 18:44:47 --> common
    Debug - 2011-07-19 18:44:48 --> CHECK
    Debug - 2011-07-19 18:44:48 --> common
    Debug - 2011-07-19 18:44:48 --> CHECK wth it check 5 times ? it works dont get me wrong ^^ i just dont get it thx
  • ok solve the problem earlier today with some help from the ppl on the irc channel, but i still feel that something is not right.
    so let me explain. my Controller_Common is extend by almost every other controller in my app and it has the before() method you can see in the post above and another for the 404 action. and that was the problem i didnt white listed the 404 action.
    this created 2 situations :
    - the one described earlier
    - and another that when a request was made to a controller or action that didnt existed the route 404 was followed to the action_404 in the Controller_Common and the before() method was executed which render the template instead of the view in the 404 action. the second is understandable but the first not so much. oh i forgot the last 4 CHECK's in the log were made by a resquest to common/404.
    so why would the script perform the first check successfully continue to the method requested (dashboard/index) and after do the additional 4x requests to common/404? thanks for the quick reply :D
  • Can't be sure from this log, the beginning seems completely logical, and after that "common" doesn't really tell me what happens so I don't know why it'd be called a second/third time. Having said that the perform_check() method should be optimized not to check a second(/third/fourth) time but just return what you already checked. Still this shouldn't happen, but based on this I'd gamble there's something going on in your own code.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion