View | Details | Raw Unified | Return to bug 24631
Collapse All | Expand All

(-)a/Koha/Plugins.pm (-8 / +12 lines)
Lines 20-25 package Koha::Plugins; Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Class::Inspector;
22
use Class::Inspector;
23
use File::Find::Rule;
23
use List::MoreUtils qw(any);
24
use List::MoreUtils qw(any);
24
use Module::Load qw(load);
25
use Module::Load qw(load);
25
use Module::Load::Conditional qw(can_load);
26
use Module::Load::Conditional qw(can_load);
Lines 30-38 use C4::Context; Link Here
30
use C4::Output;
31
use C4::Output;
31
use Koha::Plugins::Methods;
32
use Koha::Plugins::Methods;
32
33
34
our @pluginsdir;
35
33
BEGIN {
36
BEGIN {
34
    my $pluginsdir = C4::Context->config("pluginsdir");
37
    my $pluginsdir = C4::Context->config("pluginsdir");
35
    my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir;
38
    @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir;
36
    push( @INC, @pluginsdir );
39
    push( @INC, @pluginsdir );
37
    pop @INC if $INC[-1] eq '.';
40
    pop @INC if $INC[-1] eq '.';
38
}
41
}
Lines 128-148 sub GetPluginsMetadata { Link Here
128
        }
131
        }
129
    )->_resultset->get_column('plugin_class');
132
    )->_resultset->get_column('plugin_class');
130
133
134
    my @metafiles = File::Find::Rule->file()->name('META.yml')->in( @pluginsdir );
135
131
    my @plugins;
136
    my @plugins;
132
    while ( my $plugin_class = $plugin_classes->next ) {
137
    while ( my $plugin_class = $plugin_classes->next ) {
133
        my $plugin_path = $plugin_class;
138
        my $plugin_path = $plugin_class;
134
        $plugin_path =~ s/::/\//g;  # Take class name, transform :: to / to get path
139
        $plugin_path =~ s/::/\//g;  # Take class name, transform :: to / to get path
140
        my $yaml_to_find = "$plugin_path/META.yml";
135
        $plugin_path =~ s/$/.pm/;   # Add .pm to the end
141
        $plugin_path =~ s/$/.pm/;   # Add .pm to the end
136
        require $plugin_path;   # Require the plugin to have it's path listed in INC
137
        $plugin_path =
138
          $INC{$plugin_path};   # Get the full true path to the plugin from INC
139
        my $meta_yaml = "$plugin_path/META.yml";
140
142
141
        my $plugin_metadata;
143
        # Find the full path to the file, it's somewhere in the list of metafiles we found when this module as loaded
144
        my ( $meta_yaml ) = grep { $yaml_to_find eq substr( $_, -length($yaml_to_find) ) } @metafiles;
142
145
143
        if ( -r $meta_yaml ) {
146
        my $plugin_metadata;
147
        if ( -r $meta_yaml ) { # If the metafile exists and is readable, use it
144
           $plugin_metadata = YAML::LoadFile($meta_yaml);
148
           $plugin_metadata = YAML::LoadFile($meta_yaml);
145
        } else {
149
        } else { # Fall back to loading the plugin to get the metadata if there is no META.yml file to read
146
            load $plugin_class;
150
            load $plugin_class;
147
            my $plugin = $plugin_class->new({
151
            my $plugin = $plugin_class->new({
148
                enable_plugins => $self->{'enable_plugins'}
152
                enable_plugins => $self->{'enable_plugins'}
(-)a/cpanfile (-1 / +1 lines)
Lines 39-44 requires 'Email::Date', '1.103'; Link Here
39
requires 'Email::MessageID', '1.406';
39
requires 'Email::MessageID', '1.406';
40
requires 'Email::Valid', '0.190';
40
requires 'Email::Valid', '0.190';
41
requires 'Exception::Class', '1.38';
41
requires 'Exception::Class', '1.38';
42
requires 'File::Find::Rule', '0.34';
42
requires 'File::Slurp', '9999.13';
43
requires 'File::Slurp', '9999.13';
43
requires 'Font::TTF', '0.45';
44
requires 'Font::TTF', '0.45';
44
requires 'GD', '2.39';
45
requires 'GD', '2.39';
45
- 

Return to bug 24631