Tags:
create new tag
, view all tags
If a plugin breaks during a handler call, it breaks TWiki.

This is a fix:

--- lib/TWiki/Plugins.pm-       2004-04-26 22:57:10.000000000 -0500
+++ lib/TWiki/Plugins.pm        2004-04-26 22:59:38.000000000 -0500
@@ -246,7 +246,13 @@

     foreach $theHandler ( @{$registeredHandlers{$handlerName}} ) {
         # apply handler on the remaining list of args
-        $status = &$theHandler;
+        eval {
+           $status = &$theHandler;
+        };
+        if($@) {
+           TWiki::writeWarning("Plugins: $theHandler ABORTED: $@");
+           return "ABORTED: $@";
+        }
         if( $onlyOnceHandlers{$handlerName} ) {
             if( $status ) {
                 return $status;

-- MartinCleaver - 27 Apr 2004

Questions:

  1. What case did you experience that justifies this patch?
    • Calendar Plugin failed during preview - I haven't yet worked out why but I can't have the site crash -- MRJC
      • Possibly caused by a relative path in setlib.cfg? -- PTh
        • Nope - thanks for the suggestion but changing that made no difference. -- MRJC
  2. What version of TWiki does that apply to? FYI, up to and including TWikiRelease01Feb2003 Plugins could fail silently. Errors are now redirected to STDERR, e.g. Plugin compile errors should be visible in the browser via CGI::Carp
    • TWikiAlphaRelease of about 2 weeks ago
      • There is no point showing users Plugin compile errors - I want to see them in a log -- MRJC
        • And possibly never detect. I prefer an e-mail from a user reporting an error -- PTh
          • I'd prefer to wire writeWarning through AppendTextToTopic into a system web and then get notified according to whatever schedule I set on the NotificationPlugin (or indeed, get immediate notified when NotificationPlugin is adapted to send instant messages) -- MRJC
  3. What is the performance impact of changing a direct call to an eval? It might be expensive for the outsidePREHandler and insidePREHandler that are called in a tight loop/
    • I don't know. -- MRJC
      • These two handlers are the worst performance offenders. Could you provide benchmarks with/without the fix with a Plugin what uses those callbacks? -- PTh
  4. Wouldn't it be better to skip just the one faulty Plugin? You break out of the Plugin callback chain on error.
    • Yes, certainly. -- MRJC
      • But I think this is what I wrote, no? (see below - this gets called with a given handlerName - theHandler is set to each row in this table: ) -- MRJC

Output of FAILEDPLUGINS

PluginErrors
SpreadSheetPlugin none
AutoSectionsPlugin none
BackupRestorePlugin none
BlackListPlugin none
CalendarPlugin none
ChartPlugin none
ColorPickerPlugin none
CommentPlugin none
DatePickerPlugin none
EditTablePlugin none
GaugePlugin none
GeoLookupPlugin none
HeadlinesPlugin none
IfThenActionPlugin none
InterwikiPlugin none
JQueryPlugin none
LocalCityTimePlugin none
PercentCompletePlugin none
PreferencesPlugin none
QRCodePlugin none
RecentVisitorPlugin none
RenderListPlugin none
SetGetPlugin none
ShareMePlugin none
SlideShowPlugin none
SmiliesPlugin none
TWikiDrawPlugin none
TWikiOrgPlugin none
TWikiSheetPlugin none
TablePlugin none
TagMePlugin none
TinyMCEPlugin none
TwistyPlugin none
VarCachePlugin none
WatchlistPlugin none
WysiwygPlugin none
HandlerPlugins
afterAttachmentSaveHandlerIfThenActionPlugin
afterCommonTagsHandlerVarCachePlugin
afterEditHandlerWysiwygPlugin
afterRenameHandlerTagMePlugin
WatchlistPlugin
afterSaveHandlerIfThenActionPlugin
TagMePlugin
WatchlistPlugin
beforeAttachmentSaveHandlerBlackListPlugin
beforeCommonTagsHandlerAutoSectionsPlugin
EditTablePlugin
PreferencesPlugin
TWikiSheetPlugin
TwistyPlugin
VarCachePlugin
WysiwygPlugin
beforeEditHandlerAutoSectionsPlugin
TinyMCEPlugin
WysiwygPlugin
beforeMergeHandlerWysiwygPlugin
beforeSaveHandlerAutoSectionsPlugin
BlackListPlugin
CommentPlugin
WatchlistPlugin
WysiwygPlugin
commonTagsHandlerSpreadSheetPlugin
BackupRestorePlugin
BlackListPlugin
CalendarPlugin
ChartPlugin
CommentPlugin
EditTablePlugin
JQueryPlugin
LocalCityTimePlugin
SlideShowPlugin
SmiliesPlugin
TWikiOrgPlugin
TWikiSheetPlugin
completePageHandlerIfThenActionPlugin
endRenderingHandlerBlackListPlugin
This handler is deprecated - please check for updated versions of the plugins that use it!
initPluginSpreadSheetPlugin
AutoSectionsPlugin
BackupRestorePlugin
BlackListPlugin
CalendarPlugin
ChartPlugin
ColorPickerPlugin
CommentPlugin
DatePickerPlugin
EditTablePlugin
GaugePlugin
GeoLookupPlugin
HeadlinesPlugin
IfThenActionPlugin
InterwikiPlugin
JQueryPlugin
LocalCityTimePlugin
PercentCompletePlugin
PreferencesPlugin
QRCodePlugin
RecentVisitorPlugin
RenderListPlugin
SetGetPlugin
ShareMePlugin
SlideShowPlugin
SmiliesPlugin
TWikiDrawPlugin
TWikiOrgPlugin
TWikiSheetPlugin
TablePlugin
TagMePlugin
TinyMCEPlugin
TwistyPlugin
VarCachePlugin
WatchlistPlugin
WysiwygPlugin
modifyHeaderHandlerWysiwygPlugin
postRenderingHandlerBlackListPlugin
PreferencesPlugin
WysiwygPlugin
preRenderingHandlerAutoSectionsPlugin
InterwikiPlugin
SmiliesPlugin
TablePlugin
registrationHandlerIfThenActionPlugin
startRenderingHandlerRenderListPlugin
This handler is deprecated - please check for updated versions of the plugins that use it!
36 plugins

-- MartinCleaver - 27 Apr 2004

Application

sub applyHandlers
{
    my $handlerName = shift;
    my $theHandler;
    if( $TWiki::disableAllPlugins ) {
        return;
    }
    my $status;

    foreach $theHandler ( @{$registeredHandlers{$handlerName}} ) {
        # apply handler on the remaining list of args
        eval {
           $status = &$theHandler;
        };
        if($@) {
           TWiki::writeWarning("Plugins: $theHandler ABORTED: $@");
           return "ABORTED: $@";
        }
        if( $onlyOnceHandlers{$handlerName} ) {
            if( $status ) {
                return $status;
            }
        }
    }

    return undef;
}

I think we need a new TopicClassification: PatchBenchmarkingRequired

-- MartinCleaver - 16 May 2004

ChangeProposalForm
TopicClassification FeatureRequest
TopicSummary FIX for: a plugin breaks during a handler call, it breaks TWiki.
CurrentState UnderInvestigation
OutstandingIssues needs benchmarking, there is potential for really expensive operations here
RelatedTopics

InterestedParties

ProposedFor

TWikiContributors MartinCleaver
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2006-04-06 - MeredithLesly
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.