Why does view in Phalcon load twice on single request.

Hi there,

I wrote a test function like this.

    public function testAction() {
        logger("HAS BEEN CALLED", 0);
        logger($this->request->isGet() ? "This is GET" : "", 0);
        if($this->request->isPost() ) {

            logger("This is POST", 0);

        }
        $this->view->start();
        $this->view->render($this->theme, "order", "test");
        // $this->view->pick($this->theme."/"."order/test");
        $this->view->finish();
        return;
    }

Check on log file:

[INFO][2020/08/31 03:28:00 PM] test.local: HAS BEEN CALLED
[INFO][2020/08/31 03:28:00 PM] test.local: This is GET
[INFO][2020/08/31 03:28:00 PM] test.local: HAS BEEN CALLED
[INFO][2020/08/31 03:28:00 PM] test.local: This is GET

[INFO][2020/08/31 03:28:06 PM] test.local: HAS BEEN CALLED
[INFO][2020/08/31 03:28:06 PM] test.local: This is GET
[INFO][2020/08/31 03:28:07 PM] test.local: HAS BEEN CALLED
[INFO][2020/08/31 03:28:07 PM] test.local: This is GET

As you can see, when I access to /test, somehow the function testAction is called twice.

Is it normal in Phalcon or Am I wrong something?

edited 23d ago

No, that's not standard behaviour. I would do a backtrace to see what's happening:

public function testAction(){
echo '<pre>';
print_debug_backtrace(1,1);
echo '</pre>';

That will output what called testAction(). Increasing the 2nd parameter will debug more levels.



6.5k

this does happen when the developer tools is open in your browser

i noticed it in chrome and edge