Wednesday, February 27, 2013

Hash.php

(Cake 2.2.5) I recently started getting an error that reads:
Warning (2): Invalid argument supplied for foreach() [CORE]/Cake/Utility/Hash.php, Line 50]

Line 50 in Hash.php is part of get() function for the Hash class. Trying to debug anything in that function results in a memory allocation error. How is Hash being used and what kind of data is being presented to the function that it's running out of memory? 

There are only two users in the database at the moment and the error is only showing for one of them. The method in my Users controller that seems to be triggering the error is: 

public function view($id = null){
   
       if ($id == null){
           $id = $this->Auth->user('username');
       }
       $user = $this->User->getUser($id); 
       $this->set(compact('user'));
    }

getUser() in the User model is: 

public function getUser($id){
         
if (is_numeric($id)){ 
$user = $this->find('first', array(
            'conditions' => array(
                'User.id' => $id),
            'contain' => array('Avatar', 'Bio', 'Role', 'Group')
            )); 
} else { 
$user = $this->find('first', array(
            'conditions' => array(
                'username' => $id),
            'contain' => array('Avatar', 'Bio', 'Role', 'Group')
            )); 
}
        if ($user){
            return $user;
        } return false; 
    }

Wondering what Hash is looking for and why it's reporting an error with this particular method. The app has been running error free for quite some time and I can't think of anything I changed that would have produced the error. 

Any help is appreciated. 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate