Skip Menu |

This queue is for tickets about the Plucene CPAN distribution.

Report information
The Basics
Id: 17185
Status: open
Priority: 0/
Queue: Plucene

People
Owner: Nobody in particular
Requestors: NIKC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: C< Argument "foo" isn't numeric in bitwise xor (^) > in TermInfosWriter.pm
As described in http://www.kasei.com/pipermail/plucene/2005-September/000618.html, TermInfosWriter.pm has a bug with the use of xor on bitstrings. As one of the arguments may be numeric, the whole expression is numeric. The solution (also described on that page) is to explicitly stringify both arguments to force bitstring xor. Replace line 134: ($text ^ $self->{last_term}->text) =~ /^(\0*)/; With these two lines: my $last_term_text = $self->{last_term}_text; ("$text" ^ "$last_term_text") =~ /^(\0*)/; or variant thereof.
CC: plucene [...] kasei.com
Subject: Re: [rt.cpan.org #17185] C< Argument "foo" isn't numeric in bitwise xor (^) > in TermInfosWriter.pm
Date: Fri, 20 Jan 2006 13:58:56 +0000
To: via RT <bug-plucene [...] rt.cpan.org>
From: Tony Bowden <tony [...] kasei.com>
On Fri, Jan 20, 2006 at 08:05:23AM -0500, via RT wrote: Show quoted text
> As described in > http://www.kasei.com/pipermail/plucene/2005-September/000618.html, > TermInfosWriter.pm has a bug with the use of xor on bitstrings. As one > of the arguments may be numeric, the whole expression is numeric. > The solution (also described on that page) is to explicitly stringify > both arguments to force bitstring xor. > Replace line 134: > ($text ^ $self->{last_term}->text) =~ /^(\0*)/; > With these two lines: > my $last_term_text = $self->{last_term}_text; > ("$text" ^ "$last_term_text") =~ /^(\0*)/; > or variant thereof.
I'm happy to accept a patch like this if someone can put together a failing test case. Thanks, Tony
CC: NIKC [...] cpan.org
Subject: Re: [rt.cpan.org #17185] C< Argument "foo" isn't numeric in bitwise xor (^) > in TermInfosWriter.pm
Date: Fri, 20 Jan 2006 17:34:37 +0000
To: bug-plucene [...] rt.cpan.org
From: Nik Clayton <nik [...] ngo.org.uk>
Tony Bowden via RT wrote: Show quoted text
> On Fri, Jan 20, 2006 at 08:05:23AM -0500, via RT wrote:
>> As described in >> http://www.kasei.com/pipermail/plucene/2005-September/000618.html, >> TermInfosWriter.pm has a bug with the use of xor on bitstrings. As one >> of the arguments may be numeric, the whole expression is numeric. >> The solution (also described on that page) is to explicitly stringify >> both arguments to force bitstring xor. >> Replace line 134: >> ($text ^ $self->{last_term}->text) =~ /^(\0*)/; >> With these two lines: >> my $last_term_text = $self->{last_term}_text; >> ("$text" ^ "$last_term_text") =~ /^(\0*)/; >> or variant thereof.
> > I'm happy to accept a patch like this if someone can put together a > failing test case.
Here you are. I can see that it's debatable whether or not this is a bug in Plucene -- the documentation does state that the second argument to the Plucene::Document::Field methods should be a string, and not a number. However, in the spirit of Perl's general DWIMitude it's probably a good idea if Plucene does the conversion (or, at the very least, warns the user when the ::Field is created, instead of when the document is added). N #!/usr/bin/perl use warnings; use strict; use Test::More tests => 1;; use Test::Warn; use Plucene::Document; use Plucene::Document::Field; use Plucene::Analysis::SimpleAnalyzer; use Plucene::Index::Writer; my $analyzer = Plucene::Analysis::SimpleAnalyzer->new(); my $writer = Plucene::Index::Writer->new('/tmp/index', $analyzer, 1); my $doc = Plucene::Document->new(); # If this line is left as is, it triggers a warning. If the number is # stringified by quoting then it doesn't trigger the warning. $doc->add(Plucene::Document::Field->Keyword('revision', 1)); warning_is { $writer->add_document($doc); } undef, q{Numeric fields don't trigger warnings};
Subject: Re: [Plucene] Re: [rt.cpan.org #17185] C< Argument "foo" isn't numeric in bitwise xor (^) > in TermInfosWriter.pm
Date: Fri, 20 Jan 2006 16:11:36 -0600
To: via RT <bug-plucene [...] rt.cpan.org>, plucene [...] kasei.com
From: Michael Chaney <mdchaney [...] michaelchaney.com>
On Fri, Jan 20, 2006 at 01:58:56PM +0000, Tony Bowden wrote: Show quoted text
> On Fri, Jan 20, 2006 at 08:05:23AM -0500, via RT wrote:
> > As described in > > http://www.kasei.com/pipermail/plucene/2005-September/000618.html, > > TermInfosWriter.pm has a bug with the use of xor on bitstrings. As one > > of the arguments may be numeric, the whole expression is numeric. > > The solution (also described on that page) is to explicitly stringify > > both arguments to force bitstring xor. > > Replace line 134: > > ($text ^ $self->{last_term}->text) =~ /^(\0*)/; > > With these two lines: > > my $last_term_text = $self->{last_term}_text; > > ("$text" ^ "$last_term_text") =~ /^(\0*)/; > > or variant thereof.
> > I'm happy to accept a patch like this if someone can put together a > failing test case.
I had to put it in last night on a box here, but that was the least of my worries. See my next post. Michael -- Michael Darrin Chaney mdchaney@michaelchaney.com http://www.michaelchaney.com/
What is the status of this bug? The patch and test case look good.