LP#1089468: QueryParser is not re-entrant user/jcamins/lp1089468
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Thu, 13 Dec 2012 15:14:52 +0000 (10:14 -0500)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Thu, 13 Dec 2012 15:23:27 +0000 (10:23 -0500)
Because the ->parse() method of QueryParser did not clear an instance's
parse tree prior to parsing, any time a QP instance was reused, the user
ended up with a corrupted parse tree containing bits of old queries as
well as bits of the new query.

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm

index 7ee0402..0b39cac 100644 (file)
@@ -459,6 +459,11 @@ sub parse {
     my $self = shift;
     my $pkg = ref($self) || $self;
     warn " ** parse package is $pkg\n" if $self->debug;
+
+    # Without this, calling ->parse() twice on a single instance results
+    # in parse tree corruption
+    undef $self->{_parse_tree};
+
     $self->parse_tree(
         $self->decompose(
             $self->query( shift() )