Thursday, February 28, 2013

Re: Hash.php

I don't have a copy of 2.2.5 here, and I can't navigate the new online
API, but I have 2.2.4 here. That foreach() assumes that $parts is an
array, but it shouldn't.

Do you get a stack trace? Have you tried installing DebugKit? It's worth it.

On Wed, Feb 27, 2013 at 1:45 PM, Ed Propsner <crotchfrog@gmail.com> wrote:
> (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.
>
>

--
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.

No comments: