Your plugin is not recording an error message in the MT Activity Log because of a bug in MT's code. This is from lib/MT/JunkFilter.pm, lines 52-58:
CODE
# Run all the registered filters & average their results.
foreach my $filter (@MT::JunkFilters) {
my ($score, $log) = eval { $filter->{code}->($obj) };
if ($@) {
MT->instance->log(MT->translate("Junk Filter [_1] died with: [_2]", ($filter->{name} || (MT->translate("Unnamed Junk Filter"))), $@));
next;
}
Your plugin filter is run in the eval block at line 54, and if an error is returned from the eval, MT is supposed to log the error message in the Activity Log (line 56).
If an error message is returned from an eval block, the error message is stored in the perl variable $@. The problem with the above code is that, in the line that is actually logging the error (line 56), the function
MT->translate("Unnamed Junk Filter") executes an eval block of its own and sets $@ before $@ can be read, wiping out your plugin's error message. Usually, the MT->translate function will execute without error, so $@ will be set to the empty string (""), and this is what MT ends up logging as your plugin's error message.
To correct this bug, the code should save the error message in a separate variable before attempting to translate and log the error message:
CODE
# Run all the registered filters & average their results.
foreach my $filter (@MT::JunkFilters) {
my ($score, $log) = eval { $filter->{code}->($obj) };
if ($@) {
my $errmsg = $@;
MT->instance->log(MT->translate("Junk Filter [_1] died with: [_2]", ($filter->{name} || (MT->translate("Unnamed Junk Filter"))), $errmsg));
next;
}
1) Line inserted at line 56, saving the error message in $@ in the variable $errmsg.
2) At line 57, replace $@ variable at the end of line with $errmsg.
With these changes made to the MT code, the following message is now recorded in the Activity Log when a trackback is received:
QUOTE
Junk Filter Moderate Via Delay died with: Can't call method "entry_id" without a package or object reference at C:\Apache2\www\mt3\plugins\ModerateViaDelay.pl line 172.
Line 172 of ModerateViaDelay.pl is the following code:
CODE
$entry = MT::Entry->load(($obj->tb_id)->entry_id);
This code is trying to use a trackback ID number to load its corresponding entry, but is not doing it correctly.
$obj is a trackback ping (MT::TBPing object). $obj->tb_id only returns the corresponding MT::Trackback ID number (an integer), not any kind of object, so ($obj->tb_id)->entry_id is always going to result in an error.
To load an entry from a trackback ping ID, you'd need code something like the following, which uses the trackback ID to load the corresponding MT::Trackback object, gets the entry ID number, then loads that entry:
CODE
$entry = MT::Entry->load(MT::Trackback->load($obj->tb_id)->entry_id);
Hope this helps...