Wednesday, August 8, 2012

Problem with controller redirect

Hello,

Cake 2.1.3. Here's what I've got in my controller:

function company_info() {
if ($this->request->is('post')) {
if ($this->Business->save($this->request->data)) {
$this->redirect($this->request->here);
} else {
$this->raiseWarning('Your information could not be saved');
}
}
}

Problem is, when Cake gets to $this->redirect() it craps out, causing no output and no redirect (blank screen). Logs show me nothing. However, very weirdly, if I go to the redirect() method in /lib/Cake/Controller.php and make the following change at line 788:

if ($exit) {
$this->response->send();
        echo 'some random text';
$this->_stop();
}

Then it works!! ??? How is it that adding output here makes the redirect work properly? Is this a bug?

Any help appreciated. Best,
-Brian

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: