Controller Redirect Dont Work In Some Controllers change host and $this->redirect stop working.
#1
Posted 02 February 2013 - 09:40 AM
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?
#2
Posted 02 February 2013 - 02:15 PM
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.
#3
Posted 02 February 2013 - 03:58 PM
mboz62, on 02 February 2013 - 02:15 PM, said:
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',));
}
#4
Posted 03 February 2013 - 05:29 AM
public function actionCreate() {
$this->redirect( array('casa/update/'));
}
#5
Posted 03 February 2013 - 05:50 AM
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.
#7
Posted 03 February 2013 - 06:55 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.
[/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.
#8
Posted 03 February 2013 - 07:05 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.
@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
#9
Posted 03 February 2013 - 07:21 AM
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.
#10
Posted 03 February 2013 - 07:50 AM
softark, on 03 February 2013 - 07:21 AM, said:
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
#11
Posted 03 February 2013 - 08:10 AM
Led, on 03 February 2013 - 07:50 AM, said:
I know.
#13
Posted 03 February 2013 - 10:43 AM
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.
#14
Posted 03 February 2013 - 11:02 AM
softark, on 03 February 2013 - 10:43 AM, said:
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();
?>

Help












