Re: Hash.php

2013-03-03 Thread AD7six


On Wednesday, 27 February 2013 19:45:29 UTC+1, CrotchFrog 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? 


The debugger class calls it - so if you put a debug statement in there, 
you're invoking a loop. Just use php debug methods like print_r(foo);  and 
you won't self-sabotage your efforts, OR alternatively log the whatever 
instead of using debug().

That said, all errors handled by CakePHP have a stack trace (or - since 
it's not obvious from the question, is the stack trace responsible for the 
loop? how?) so just look what is calling hash and specifically what is the 
second argument since it's not a string, not numeric and not an array. 

AD



-- 
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+unsubscr...@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.




Re: Hash.php

2013-03-01 Thread CrotchFrog
Looking at the stack trace, there was nothing that seemed to point to the 
cause of the problem. I'm at work now but I'll post a trace over the 
weekend. I use DebugKit from time to time, but it's usually off more often 
than not. I'll run it through DebugKit and see what I can come up with. The 
biggest mystery to me now is why did the error start all of the sudden 
and why for some users and not others. 

On Wednesday, February 27, 2013 1:45:29 PM UTC-5, CrotchFrog 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+unsubscr...@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.




Re: Hash.php

2013-02-28 Thread lowpass
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 crotchf...@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+unsubscr...@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+unsubscr...@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.




Hash.php

2013-02-27 Thread Ed Propsner
(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+unsubscr...@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.