Skip to main content.
home | support | download

Back to List Archive

search.cgi bug w.r.t. mod_perl?

From: Greg Fenton <greg_fenton(at)not-real.yahoo.com>
Date: Tue Jun 01 2004 - 05:53:44 GMT
SWISH-E 2.4.2
mod_perl 1.0
Apache 1.3.27
RH 7.3
Perl 5.6.1


We have built a new mod_perl search script based on the sample code in
search.cgi.  I simply sat on a results page clicking reload in my
browser about 10-15 times and then I got a Server Error.

The error_log indicates:

[Tue Jun  1 00:19:35 2004] [error] undef error - Can't call method
"highlight" on an undefined value at /home/apache/cgi-bin/search line
302.!

This code comes straight from search.cgi (though line numbers and
indenting are slightly different):

    $template->context->define_filter('highlight',
             sub {
                  my ( $context,  $metaname ) = @_;
                  my $phrases =
                    $parsed_query->{$metaname};
                  return sub {
                      my $text = shift;
                      $highlight_object->highlight(\$text,   # <--302
                                             $phrases);
                      return $text;
                  }
              },  1 );


After digging around in the mod_perl 1.0 docs, it appears to me that
this is an instance of The First Mystery at:

http://perl.apache.org/docs/1.0/guide/porting.html#Exposing_Apache__Registry_secrets

Changing the declaration of the "cached" variables from:

   my ( ..., $swish, $highlight_object, ...);

to 

   our ( ..., $swish, $highlight_object, ...);

seems to make the problem disappear.  I've made all "my" declarations
in this script "our" instead...though this may not be necessary.

I'd be very happy to hear that I'm wrong on this...or be given a better
solution than the one above.

Hope this helps,
greg_fenton.

=====
Greg Fenton
greg_fenton@yahoo.com


	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 
Received on Mon May 31 22:53:45 2004