[Koha-bugs] [Bug 20950] New: Plugins: Handler.pm doesn't fail gracefully when running plugin

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jun 15 12:55:56 CEST 2018


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20950

            Bug ID: 20950
           Summary: Plugins: Handler.pm doesn't fail gracefully when
                    running plugin
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5 - low
         Component: Tools
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: andrew.isherwood at ptfs-europe.com
        QA Contact: testopia at bugs.koha-community.org

When running a plugin that fails for some internal reason, the user doesn't
always receive a very helpful message. With the Kitchen Sink plugin (
https://github.com/bywatersolutions/koha-plugin-kitchen-sink ) I managed to
break it by trying to import C4::Members::GetMember - which doesn't exist any
more.

Running the plugin in this broken state resulted in:

run.pl: Plugin Koha::Plugin::Com::ByWaterSolutions::KitchenSink cannot be
loaded at /usr/share/koha/Koha/Plugins/Handler.pm line 72.:
/usr/share/koha/plugins/run.pl

It turns out that Koha::Plugins::Handler::run calls
Module::Load::Conditional::can_load, which was returning false, which caused
the message I saw to be output. However, Module::Load::Conditional sets a
global variable upon can_load returning false containing the reason. We should
display this (assuming we don't consider it to be a security risk).

So, in Handler.pm, we'd need to substitute in:

if ( can_load( modules => { $plugin_class => undef } ) ) {
    my $plugin = $plugin_class->new( { cgi => $cgi, enable_plugins =>
$args->{'enable_plugins'} } );
    if ( $plugin->can($plugin_method) ) {
        return $plugin->$plugin_method( $params );
    } else {
        warn "Plugin does not have method $plugin_method";
    }
} else {
    warn "Plugin $plugin_class cannot be loaded: " .
$Module::Load::Conditional::ERROR;
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list