Action Being Executed Twice?

Hello guys.

After noticing that running $model->save was inserting twice on my table, i discovered that the actions of a controller are being executed Twice. I’ve even tested recording stuff in the app session.


public function actionTest(){

            $_SESSION['dump'][] = 1;

            

            var_dump($_SESSION['dump']);

}

Running the code above (localhost/controller/test) i notice that the position ‘dump’ on my session always get 2 more indexes. That is weird.

Any thoughts on what may be happening?

PS: Ajax Calls only get executed once.

[size=2]Are you executing this action from AJAX call ?? or http request by browser.[/size]

I’ve tryed both ways.

On http request by browser the variable is iterated twice.

On Ajax Calls the variable is only iterated once.

[size=2]Ok, so lets share your controller action code. lets see what’s wrong there.[/size]




public function actionTest(){

    $_SESSION['dump'][] = 1;

            

    var_dump($_SESSION['dump']);

}



Each time i execute this action on http request by browser the dump returned has 2 more indexes.




public function actionFecharPedido(){

            //if(Yii::app()->request->isAjaxRequest){

                $pedidoArray = Yii::app()->session['pedido'];

                if(isset($pedidoArray) && isset($pedidoArray['produtos']) && isset($pedidoArray['restaurante'])){

                    if(!isset($pedidoArray['formaPagamento'])){

                        Yii::app()->user->setFlash('error', "Escolha uma forma de pagamento");

                        $this->redirect('confirmacao');

                    }

                    if(!isset($pedidoArray['localEntrega'])){

                        Yii::app()->user->setFlash('error', "Defina um local de entrega");

                        $this->redirect('confirmacao');

                    }

                    $model = new Pedido();


                    $model->usuario_id      = Yii::app()->user->id;

                    $model->restaurante_id  = $pedidoArray['restaurante']->id;

                    $model->valor_total     = $this->calculaTotal($pedidoArray['produtos'],$pedidoArray['restaurante']->id, $pedidoArray['restaurante']->taxa_entrega);

                    $model->status_id       = 1;

                    $model->endereco_id     = $pedidoArray['localEntrega']->id;  


                    if($model->save()){

                        //do whatever

                    }

                    


                }else{

                    $this->redirect(array('site/index'));

                }  

            //}

        }




This is the action on wich i’ve discovered this behavior.

Just tested out same exactly same code local on another machine. Worked just fine.

May it be my application Server? Some dirt running on my appache?