Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cakephp Error: An internal error has occurred

I have some code in cakephp which produces an error.

Here is the PHP Controller:

$this->loadModel( 'Vote' ); //Newly added by amit start
$vote=$this->Vote->getVote($id,$uid);
$this->set('vote',$vote);
$voteCount = count($vote);
$this->set('voteCount',$voteCount);

$voteShow = $this->Vote->find('all', array(
    'fields' => array('SUM(Vote.score)   AS score','count(id) as countId'),
     'conditions'=>array('Vote.type_id'=>$id),
));
$this->set('voteShow',$voteShow);

model:

public function getVote($id,$uid) {
    if (empty($conditions))
        $conditions = array('Vote.type' => 'blog',
                            'Vote.type_id' => $id,
                            'Vote.user_id' => $uid);

    $users = $this->find('all', array('conditions' => $conditions,
        'order' => 'Vote.id desc'
    ));
    return $users;
}

That code produces this error:

Error : An internal error has occurred

What does this error mean?

like image 343
Amit Chowdhury Avatar asked Nov 30 '13 17:11

Amit Chowdhury


2 Answers

I enabled debug mode: Configure::write('debug', 2); in core.php and it solved my problem.

like image 172
Amit Chowdhury Avatar answered Dec 01 '22 11:12

Amit Chowdhury


In my case debug mode was Configure::write('debug', 0); on live server in core.php.

I set it to Configure::write('debug', 1); and no error was shown this time.

So I again changed my debug mode to Configure::write('debug', 0); because I don't want to show debug error on my live site.

This time no error message shows up.

So just changing the debug mode once in core.php get rid of this error in my case.

If you change your debug mode to 1 and then run those functions which you have changed on local, CakePHP will refresh the cache for all those models which include in those functions. Now you can change back to Configure::write('debug', 0).

like image 27
Dexture Avatar answered Dec 01 '22 11:12

Dexture