At long last, we're moving to forums powered by, well, Movable Type itself. You'll want to bookmark http://forums.movabletype.org/ for future reference, and in the meantime you can view these old forums as a read-only archive of past posts. Thanks for being part of the community!
![]() ![]() |
Dec 20 2005, 04:17 PM
Post
#1
|
|
|
Group: Members Posts: 5 Joined: 5-August 05 Member No.: 32,385 |
Is there a way to get more detailed error messages when a plugin dies? My website logs errors, but it doesn't log these plugin errors. All I see is stuff like this in the MT activity log:
2005.12.20 23:29:48 [IP Address] Junk Filter Moderate Via Delay died with: Can I get anything more helpful? |
|
|
|
Dec 20 2005, 08:47 PM
Post
#2
|
|
|
Technical Services Group: Six Apart Moderators Posts: 1,088 Joined: 30-October 05 Member No.: 33,516 |
This is probably something the plugin author would need to add to the plugin code. But I see on the ModerateViaDelay page that the plugin dies with TrackBacks. Is that what you're seeing?
-------------------- |
|
|
|
Dec 20 2005, 09:19 PM
Post
#3
|
|
|
Group: Members Posts: 5 Joined: 5-August 05 Member No.: 32,385 |
QUOTE (sarah @ Dec 21 2005, 04:47 AM) This is probably something the plugin author would need to add to the plugin code. But I see on the ModerateViaDelay page that the plugin dies with TrackBacks. Is that what you're seeing? I'm actually the plugin author. It mysteriously dies under other conditions, too. I can't even figure out which line of code I need to be looking at, or anything. |
|
|
|
Dec 22 2005, 12:18 AM
Post
#4
|
|
|
Group: Members Posts: 2,106 Joined: 19-October 03 From: Vallejo, CA Member No.: 16,834 |
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... -------------------- David Phillips (TweezerMan)
The Tweezer's Edge v3 |
|
|
|
Dec 22 2005, 03:20 PM
Post
#5
|
|
|
Technical Services Group: Six Apart Moderators Posts: 1,088 Joined: 30-October 05 Member No.: 33,516 |
A bug report does exist for this behaviour, so will be addressed in a future version.
-------------------- |
|
|
|
Jan 2 2006, 05:40 PM
Post
#6
|
|
|
Group: Members Posts: 5 Joined: 5-August 05 Member No.: 32,385 |
QUOTE (TweezerMan @ Dec 22 2005, 08:18 AM) Your plugin is not recording an error message in the MT Activity Log because of a bug in MT's code. (etc) 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... That helped tremendously. Everything seems to be working great now. Thanks! |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 11.24.09 - 11:46 PM |