Yii Framework Forum: Controller Redirect Dont Work In Some Controllers - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Controller Redirect Dont Work In Some Controllers change host and $this->redirect stop working. Rate Topic: -----

#1 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 16-January 12

Posted 02 February 2013 - 09:40 AM

It works in xammp ,ubuntu lamp and windows shared host plan.

Change plan to linux shared host and $this->redirect stop working in at least 2 controllers.

Debugg ok, code reach redirect but nothing hapens.

possible causes?

Any help?
0

#2 User is offline   mboz62 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 01-May 12
  • Location:Stoke-on-Trent - England

Posted 02 February 2013 - 02:15 PM

Personally I would start by looking at the network traffic. Either using a packet sniffer or something like fiddler. See if the redirects are coming through.

The host shouldn't have any influence on a redirect response being sent.

Try using just a base package, that doesn't do anything else but redirect, see what that does.

I think it is just a matter of eliminating things at this stage.
0

#3 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 16-January 12

Posted 02 February 2013 - 03:58 PM

View Postmboz62, on 02 February 2013 - 02:15 PM, said:

Personally I would start by looking at the network traffic. Either using a packet sniffer or something like fiddler. See if the redirects are coming through.

The host shouldn't have any influence on a redirect response being sent.

Try using just a base package, that doesn't do anything else but redirect, see what that does.

I think it is just a matter of eliminating things at this stage.


thanks for your help.

this is all the code in action.

no redirect at all, and blankscreen


public function actionCreate() {

        $Pagamento = new ReservaPayment();
        $Reserva = new Reserva();
        $model = new Preco('create');
       // $this->actionValida();
       // $uid = Yii::app()->user->name == ("admin") ? " >=1" : "=" . Yii::app()->user->id;
        $cod_casa = Yii::app()->getRequest()->getQuery('cod_casa');

       // $this->actionCalendar($cod_casa, 0);
        // $this->performAjaxValidation($model);

      /*  if (isset($_POST['Preco'])) {

            $model->attributes = $_POST['Preco'];

            if ($model->save()) {

                Yii::app()->user->setFlash('success', 'Ok com disponibilidade!', true);
                $id = Yii::app()->db->lastInsertID;

                if (isset($_POST['Reserva'])) {

                    $Reserva->attributes = $_POST['Reserva'];
                    $Reserva->valor=$_POST['Preco']['preco'];
                    $Reserva->user = $_POST['Reserva']['user'];
                    $Reserva->idpreco = $id;
                    $Reserva->reserva_state = $_POST['Reserva']['reserva_state'];

                    if ($Reserva->save()) {

                        $idreserva = Yii::app()->db->lastInsertID;
                       
                        $Reserva->checkOutdated($id);

                        $Reserva->sendMails($idreserva,NULL);
     
                    } else {
                        Yii::app()->user->setFlash('error', 'Erro com Reserva!', true);
                    }
                }
                if (isset($_POST['ReservaPayment'])) {


                    $Pagamento->attributes = $_POST['ReservaPayment'];
                    if (isset($idreserva)) {
                        $Pagamento->idreserva = $idreserva;
                    }
                    $Pagamento->idpreco = $id;

                    if ($Pagamento->save()) {
                        Yii::app()->user->setFlash('success', 'Ok com Periodo Reserva Pagamento !', true);
                    } else {
                        Yii::app()->user->setFlash('error', 'Pagamento não introduzido !', true);
                    }
                }
            }
        } else {

            Yii::app()->user->setFlash('error', 'Erro com Periodo Reserva e pagamento! Confira as datas em conflito', true);
        }
        if (isset($idreserva)) {
           
            $this->redirect( array('reserva/view/','id' => $idreserva, 'fromP' => '1',));
        } else {
            $this->redirect( array('casa/update/','id' => $cod_casa, 'fromP' => '1',));
        }*/
         $this->redirect( array('casa/update/','id' => $cod_casa, 'fromP' => '1',));
    }

0

#4 User is offline   mboz62 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 01-May 12
  • Location:Stoke-on-Trent - England

Posted 03 February 2013 - 05:29 AM

What happens if you just do this...


public function actionCreate() {

         $this->redirect( array('casa/update/'));
    }

0

#5 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,085
  • Joined: 16-February 11
  • Location:Japan

Posted 03 February 2013 - 05:50 AM

Hi Led,
I would also like to suggest you to check $cod_casa query parameter.

public function actionCreate() {
         $cod_casa = Yii::app()->getRequest()->getQuery('cod_casa', "empty");
         Yii::trace("cod_casa = $cod_casa");
         $this->redirect( array('casa/update/','id' => $cod_casa, 'fromP' => '1',));
    }


My guess is that actionCreate fails to get a valid $cod_casa in some situation, and createUrl() fails because of that.
0

#6 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 16-January 12

Posted 03 February 2013 - 06:50 AM

View Postmboz62, on 03 February 2013 - 05:29 AM, said:

What happens if you just do this...


public function actionCreate() {

         $this->redirect( array('casa/update/'));
    }




@ mboz62

yes it works
0

#7 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 16-January 12

Posted 03 February 2013 - 06:55 AM

[quote name='softark' timestamp='1359888656' post='191588']
Hi Led,
I would also like to suggest you to check $cod_casa query parameter.

public function actionCreate() {
         $cod_casa = Yii::app()->getRequest()->getQuery('cod_casa', "empty");
         Yii::trace("cod_casa = $cod_casa");
         $this->redirect( array('casa/update/','id' => $cod_casa, 'fromP' => '1',));
    }


My guess is that actionCreate fails to get a valid $cod_casa in some situation, and createUrl() fails because of that.
[/quote

@softark

it works with $cod_casa = Yii::app()->getRequest()->getQuery('cod_casa', "empty"); and full action code above, but no save no flash messages.
This is very starnge

IMO this has to do with php config someway.
0

#8 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 16-January 12

Posted 03 February 2013 - 07:05 AM

[quote name='Led' timestamp='1359892559' post='191595']
[quote name='softark' timestamp='1359888656' post='191588']
Hi Led,
I would also like to suggest you to check $cod_casa query parameter.

public function actionCreate() {
         $cod_casa = Yii::app()->getRequest()->getQuery('cod_casa', "empty");
         Yii::trace("cod_casa = $cod_casa");
         $this->redirect( array('casa/update/','id' => $cod_casa, 'fromP' => '1',));
    }


My guess is that actionCreate fails to get a valid $cod_casa in some situation, and createUrl() fails because of that.
[/quote

@softark

it works with $cod_casa = Yii::app()->getRequest()->getQuery('cod_casa', "empty"); and full action code above, but no save no flash messages.
This is very starnge

IMO this has to do with php config someway.


@softark why redirect dont work in other controller that dont get a parameter.
ex:

another controller
 public function actionCreate() {
        if (Yii::app()->user->name == '***@sapo.pt') {
            $model = new Casa('admin');
        } else {
            $model = new Casa('notCertif');
        }
        //Uncomment the following line if AJAX validation is needed
        $this->performAjaxValidation($model);

        if (isset($_POST['Casa'])) {
            $model->attributes = $_POST['Casa'];
            if ($model->save()) {
                $id = Yii::app()->db->lastInsertID;

                $fbpost = new FbPost();
                $fbpost->post($id, 'casa');
                $this->redirect(array('update', 'id' => $id));
            }
        }

        $this->render('create', array(
            'model' => $model,
        ));
    }


here the padron is
$id = Yii::app()->db->lastInsertID;

but what intrigues me is it works in other 3 diferent environments. localhost lamp(ubuntu), localhost wammp(windows7) ,shared host windows server.

http://www.casasdapraia.pt/phpinfo.php
0

#9 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,085
  • Joined: 16-February 11
  • Location:Japan

Posted 03 February 2013 - 07:21 AM

I think that problem is not in redirection.
It's only my guess, but your app stops somewhere else before doing redirection.
I would run the app with full debugging options in the problematic environment and see what's really happening by looking at the log.

[P.S.]
Another thing comes to my mind is a, well, I call it "favicon.ico problem".
When there's no favicon.ico in the root, some browser will repeat the same identical request twice. It may explain why you loose the flash message.
0

#10 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 16-January 12

Posted 03 February 2013 - 07:50 AM

View Postsoftark, on 03 February 2013 - 07:21 AM, said:

I think that problem is not in redirection.
It's only my guess, but your app stops somewhere else before doing redirection.
I would run the app with full debugging options in the problematic environment and see what's really happening by looking at the log.

[P.S.]
Another thing comes to my mind is a, well, I call it "favicon.ico problem".
When there's no favicon.ico in the root, some browser will repeat the same identical request twice. It may explain why you loose the flash message.



"it works in other 3 diferent environments. localhost lamp(ubuntu), localhost wammp(windows7) ,shared host windows server."

change host and use it to another domain
0

#11 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,085
  • Joined: 16-February 11
  • Location:Japan

Posted 03 February 2013 - 08:10 AM

View PostLed, on 03 February 2013 - 07:50 AM, said:

"it works in other 3 diferent environments. localhost lamp(ubuntu), localhost wammp(windows7) ,shared host windows server."

I know. :) But saying that doesn't help you a bit, because it doesn't work in your current environment. I understand your frustration, but you have to debug in your current environment.
0

#12 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 16-January 12

Posted 03 February 2013 - 10:12 AM

View Postsoftark, on 03 February 2013 - 08:10 AM, said:

I know. :) But saying that doesn't help you a bit, because it doesn't work in your current environment. I understand your frustration, but you have to debug in your current environment.


point me a direction to debug on host ,firephp?
0

#13 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,085
  • Joined: 16-February 11
  • Location:Japan

Posted 03 February 2013 - 10:43 AM

There's nothing special. Just do as you do in your development phase.

In php.ini
1) Set error_reporting to E_ALL.
2) Set display_errors to On.

In /index.php
1) Set "YII_DEBUG" to true.

And see what's happening. You may want to check /protected/runtime/application.log. And also you may want to insert some "Yii::trace()" in your code to trace the code execution.

[Note]
I'm in the assumption that your code has a hidden flaw that has not been revealed in other environments. I might be wrong and the cause of the problem might not be in your code.
Sorry, if I'm wrong.
0

#14 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 16-January 12

Posted 03 February 2013 - 11:02 AM

View Postsoftark, on 03 February 2013 - 10:43 AM, said:

There's nothing special. Just do as you do in your development phase.

In php.ini
1) Set error_reporting to E_ALL.
2) Set display_errors to On.

In /index.php
1) Set "YII_DEBUG" to true.

And see what's happening. You may want to check /protected/runtime/application.log. And also you may want to insert some "Yii::trace()" in your code to trace the code execution.

[Note]
I'm in the assumption that your code has a hidden flaw that has not been revealed in other environments. I might be wrong and the cause of the problem might not be in your code.
Sorry, if I'm wrong.


thanks . i'll see what i can do and give some feedback
index.php:

<?php



// change the following paths if necessary
$yii=dirname(__FILE__).'/framework_latest/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($yii);
Yii::createWebApplication($config)->run();




?>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users