简体   繁体   中英

Redirection Loop in CakePHP Application

I am using CakePHP v1.2 for my web application hosted here: http://lol-land.in

The application was working fine till Yesterday, but it suddenly started to get stuck in some redirection loops. What makes it weirder is the fact that the problem is with just one controller: posts. And even in that most of the functions are working. But http://lol-land.in/posts is redirecting to lol-land.in/posts/view/133 which is in turn redirecting to itself.

Actually 110 of the 117 posts of the form /posts/view/ are stuck in this 302 redirection.

Can anyone please tell me what could have caused this?

[CakePHP 1.3 and PHP5]

Edit: Adding View Logic

function view($id = null) {
$this->log("View Logic Entry", LOG_DEBUG);
// These Log entires are missing 

$this->layout = 'postview';
if (!$id) {
    $this->Session->setFlash(__('Invalid Post.', true));
    $this->log("Redirect due to missing id", LOG_DEBUG);
    $this->redirect(array('action'=>'index'));
}
$log = $this->Session->read('Auth.User');
$logid = $log['id'];

$temp = $this->Post->read(null, $id);

$ratings = $temp['Rating'];

$this->set(compact('up', 'down', 'userrated', 'userrateid'));

$coms = $temp['Comment'];
$comuser = array();
for ($i=0; $i<count($coms); $i++) {
    $comuser[$i] = $coms[$i]['user_id'];
}
$comuser = $this->Post->User->find('list', array( 'fields'=>array('User.id', 'User.username'),
                      'conditions'=>array("User.id" => $comuser)
                      ));
$this->set(compact('comuser'));

$this->pageTitle = $temp['Post']['title'];
$this->set('post', $temp);
$alltypes = $this->Post->Type->find('list', array('fields'=> array('Type.id', 'Type.typename')));
$selectedtab = -1;
$this->set(compact('alltypes', 'selectedtab' ));


//Calling updateFBStats
// Removed because unnecessary.

}

Chances are you are either 1) using circular references with the Auth component OR 2) the function in your controller is redirecting do to something within the method. Can you show the code of posts_controller.php function view() ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM