Mailing List Archive

svn commit: r454510 - /spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
Author: jm
Date: Mon Oct 9 14:04:19 2006
New Revision: 454510

URL: http://svn.apache.org/viewvc?view=rev&rev=454510
Log:
bug 4777: finish_tests() shouldn't need to know about the internal structure of rule storage to delete the generated-code methods; instead, just store their names in an array when they're created

Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?view=diff&rev=454510&r1=454509&r2=454510
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Mon Oct 9 14:04:19 2006
@@ -1374,44 +1374,6 @@

sub finish_tests {
my ($conf) = @_;
-
- foreach my $priority (keys %{$conf->{priorities}}) {
- # clean up priority value so it can be used in a subroutine name
- my $clean_priority;
- ($clean_priority = $priority) =~ s/-/neg/;
-
- if (defined &{'_head_tests_'.$clean_priority}) {
- undef &{'_head_tests_'.$clean_priority};
- }
- foreach my $rulename (keys %{$conf->{head_tests}->{$priority}}) {
- undef &{$rulename.'_head_test'};
- }
- if (defined &{'_body_tests_'.$clean_priority}) {
- undef &{'_body_tests_'.$clean_priority};
- }
- foreach my $rulename (keys %{$conf->{body_tests}->{$priority}}) {
- undef &{$rulename.'_body_test'};
- }
- if (defined &{'_body_uri_tests_'.$clean_priority}) {
- undef &{'_body_uri_tests_'.$clean_priority};
- }
- foreach my $rulename (keys %{$conf->{uri_tests}->{$priority}}) {
- undef &{$rulename.'_uri_test'};
- }
- if (defined &{'_rawbody_tests_'.$clean_priority}) {
- undef &{'_rawbody_tests_'.$clean_priority};
- }
- foreach my $rulename (keys %{$conf->{rawbody_tests}->{$priority}}) {
- undef &{$rulename.'_rawbody_test'};
- }
- if (defined &{'_full_tests_'.$clean_priority}) {
- undef &{'_full_tests_'.$clean_priority};
- }
- if (defined &{'_meta_tests_'.$clean_priority}) {
- undef &{'_meta_tests_'.$clean_priority};
- }
- }
-
foreach my $method (@TEMPORARY_METHODS) {
if (defined &{$method}) {
undef &{$method};
@@ -1842,6 +1804,7 @@
}
}
';
+ push (@TEMPORARY_METHODS, $rulename.'_head_test');
}
else {
# store for use below
@@ -1911,8 +1874,10 @@
$self->{rule_errors}++;
}
else {
+ my $method = '_head_tests_'.$clean_priority;
+ push @TEMPORARY_METHODS, $method;
no strict "refs";
- &{'Mail::SpamAssassin::PerMsgStatus::_head_tests_'.$clean_priority}($self);
+ &{$method}($self);
use strict "refs";
}
}
@@ -2009,6 +1974,7 @@
$evalstr2 .= '
sub '.$rulename.'_body_test { my $self = shift; '.$sub.' }
';
+ push (@TEMPORARY_METHODS, $rulename.'_body_test');
}
}

@@ -2042,8 +2008,10 @@
$self->{rule_errors}++;
}
else {
+ my $method = '_body_tests_'.$clean_priority;
+ push @TEMPORARY_METHODS, $method;
no strict "refs";
- &{'Mail::SpamAssassin::PerMsgStatus::_body_tests_'.$clean_priority}($self, @$textary);
+ &{$method}($self,@$textary);
use strict "refs";
}
}
@@ -2454,6 +2422,7 @@
$evalstr2 .= '
sub '.$rulename.'_uri_test { my $self = shift; '.$sub.' }
';
+ push (@TEMPORARY_METHODS, $rulename.'_uri_test');
}
}

@@ -2487,8 +2456,10 @@
$self->{rule_errors}++;
}
else {
+ my $method = '_body_uri_tests_'.$clean_priority;
+ push @TEMPORARY_METHODS, $method;
no strict "refs";
- &{'Mail::SpamAssassin::PerMsgStatus::_body_uri_tests_'.$clean_priority}($self, @uris);
+ &{$method}($self, @uris);
use strict "refs";
}
}
@@ -2579,6 +2550,7 @@
$evalstr2 .= '
sub '.$rulename.'_rawbody_test { my $self = shift; '.$sub.' }
';
+ push (@TEMPORARY_METHODS, $rulename.'_rawbody_test');
}
}

@@ -2612,8 +2584,10 @@
$self->{rule_errors}++;
}
else {
+ my $method = '_rawbody_tests_'.$clean_priority;
+ push @TEMPORARY_METHODS, $method;
no strict "refs";
- &{'Mail::SpamAssassin::PerMsgStatus::_rawbody_tests_'.$clean_priority}($self, @$textary);
+ &{$method}($self, @$textary);
use strict "refs";
}
}
@@ -2686,8 +2660,10 @@
warn "rules: failed to compile full tests, skipping:\n" . "\t($@)\n";
$self->{rule_errors}++;
} else {
+ my $method = '_full_tests_'.$clean_priority;
+ push @TEMPORARY_METHODS, $method;
no strict "refs";
- &{'Mail::SpamAssassin::PerMsgStatus::_full_tests_'.$clean_priority}($self, $fullmsgref);
+ &{$method}($self, $fullmsgref);
use strict "refs";
}
}
@@ -2901,8 +2877,10 @@
$self->{rule_errors}++;
}
else {
+ my $method = '_meta_tests_'.$clean_priority;
+ push @TEMPORARY_METHODS, $method;
no strict "refs";
- &{'Mail::SpamAssassin::PerMsgStatus::_meta_tests_'.$clean_priority}($self);
+ &{$method}($self);
use strict "refs";
}
} # do_meta_tests()
@@ -3081,6 +3059,7 @@
$self->{rule_errors}++;
}
else {
+ push (@TEMPORARY_METHODS, $methodname);
no strict "refs";
&{'Mail::SpamAssassin::PerMsgStatus::'.$methodname}($self,@extraevalargs);
use strict "refs";