logo       

$m->callers() dies with argument greater than or equal to stack depth: msg#00214

web.mason.user

Subject: $m->callers() dies with argument greater than or equal to stack depth

calling $m->callers() with an argument that is greater than one less
than the stack depth produces an error. for example, calling
$m->callers(2) from a component that is only two components deep (called
from the autohandler) dies with "Can't use an undefined value as a HASH
reference at /usr/lib/perl5/site_perl/5.6.1/HTML/Mason/Request.pm line
767."

this means that you can't use
my $grandparent = $m->callers(2);
if ( defined( $grandparent ) ) {
...
}
to check for existence of a particular component at a certain point in
the lineage.

i suppose you could do
my @caller_array = $m->callers();
if ( @caller_array > 2 ) {
if ( defined( $grandparent ) ) {
...
}
}
but it doesn't seem like you should have to.

the offending lines are

sub callers
{
my $self = shift;
if (defined $_[0]) {
return $self->stack_entry($_[0])->{comp};
} else {
return map($_->{comp}, reverse $self->stack);
}
}

and probably should be


sub callers
{
my $self = shift;
if (defined $_[0] && defined $self->stack_entry($_[0])) {
return $self->stack_entry($_[0])->{comp};
} else {
return map($_->{comp}, reverse $self->stack);
}
}




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise