On Tue, Nov 18, 2003 at 03:57:54PM -0800, David White wrote:
> However, if I use the <SELECT> box code listed at the top of this page
> (and select "Search All Sites"), then the code breaks, and I get a
> "Index file error: Could not open the index file 'index.swish-e': No
> such file or directory" error.
>
> I've discovered this is because selecting a "null" value <option> in a
> <select> box creates a GET request that contains "si=" . The Perl CGI
> module interprets this as a null value, and dutifully populates the
> "si" array with a single (null) value. And that's not the same thing
> as having NO "si" value at all. Since "si" has a null value, swish-e
> doesn't bother using the default_index(es).
>
> My kludge to work around this so far has been to edit swish.cgi (2.4.0
> release version) and change line 1382 from:
>
> if ( !@choices ) {
>
> to:
>
> if ( !@choices || ($#choices == 0 && !$choices[0])) {
>
> It's a ugly hack, but at the moment it's the only way I know how to
> accomplish what I want to do. Does anyone have a better suggestion how
> I could tackle this problem?
I'm not testing at the moment, so these may or may not work.
I wonder if you could do this instead.
my @choices = $q->param('si') if $q->param('si');
No there's also an undocumented call-back that you can use in your
.swishcgi.conf file.
# Allow fixup within the config file
if ( $conf->{request_fixup} && ref $conf->{request_fixup} eq 'CODE' ) {
&{$conf->{request_fixup}}( $request_object, $conf );
}
So (again, untested) in the .swishcgi.conf file you might be able to do:
request_fixup => sub {
my ( $cgi, $conf ) = @_;
if ( defined $cgi->param('si') && !$cgi->param('si') ) {
$cgi->delete('si');
}
},
So, in other words, delete the "si" parameter if it exists but is blank
or zero.
I added that callback as a way to modify the incoming CGI data.
--
Bill Moseley
moseley@hank.org
Received on Wed Nov 19 14:41:30 2003