Lines 21-32
use Modern::Perl;
Link Here
|
21 |
|
21 |
|
22 |
use Cwd qw( abs_path ); |
22 |
use Cwd qw( abs_path ); |
23 |
use List::Util qw( max ); |
23 |
use List::Util qw( max ); |
|
|
24 |
use Try::Tiny; |
24 |
|
25 |
|
25 |
use base qw{Module::Bundled::Files}; |
26 |
use base qw{Module::Bundled::Files}; |
26 |
|
27 |
|
27 |
use C4::Context; |
28 |
use C4::Context; |
28 |
use C4::Output qw( output_with_http_headers ); |
29 |
use C4::Output qw( output_with_http_headers ); |
29 |
|
30 |
|
|
|
31 |
use Koha::Exceptions::Plugin; |
32 |
|
30 |
=head1 NAME |
33 |
=head1 NAME |
31 |
|
34 |
|
32 |
Koha::Plugins::Base - Base Module for plugins |
35 |
Koha::Plugins::Base - Base Module for plugins |
Lines 48-68
sub new {
Link Here
|
48 |
|
51 |
|
49 |
## Run the installation method if it exists and hasn't been run before |
52 |
## Run the installation method if it exists and hasn't been run before |
50 |
if ( $self->can('install') && !$self->retrieve_data('__INSTALLED__') ) { |
53 |
if ( $self->can('install') && !$self->retrieve_data('__INSTALLED__') ) { |
51 |
if ( $self->install() ) { |
54 |
try { |
52 |
$self->store_data( { '__INSTALLED__' => 1, '__ENABLED__' => 1 } ); |
55 |
if ( $self->install() ) { |
53 |
if ( my $version = $plugin_version ) { |
56 |
$self->store_data( { '__INSTALLED__' => 1, '__ENABLED__' => 1 } ); |
54 |
$self->store_data({ '__INSTALLED_VERSION__' => $version }); |
57 |
if ( my $version = $plugin_version ) { |
|
|
58 |
$self->store_data({ '__INSTALLED_VERSION__' => $version }); |
59 |
} |
60 |
} else { |
61 |
warn "Plugin $class failed during installation!"; |
55 |
} |
62 |
} |
56 |
} else { |
|
|
57 |
warn "Plugin $class failed during installation!"; |
58 |
} |
63 |
} |
|
|
64 |
catch { |
65 |
Koha::Exceptions::Plugin::InstallDied->throw( plugin_class => $class ); |
66 |
}; |
59 |
} elsif ( $self->can('upgrade') ) { |
67 |
} elsif ( $self->can('upgrade') ) { |
60 |
if ( _version_compare( $plugin_version, $database_version ) == 1 ) { |
68 |
if ( _version_compare( $plugin_version, $database_version ) == 1 ) { |
61 |
if ( $self->upgrade() ) { |
69 |
try { |
62 |
$self->store_data({ '__INSTALLED_VERSION__' => $plugin_version }); |
70 |
if ( $self->upgrade() ) { |
63 |
} else { |
71 |
$self->store_data({ '__INSTALLED_VERSION__' => $plugin_version }); |
64 |
warn "Plugin $class failed during upgrade!"; |
72 |
} else { |
|
|
73 |
warn "Plugin $class failed during upgrade!"; |
74 |
} |
65 |
} |
75 |
} |
|
|
76 |
catch { |
77 |
Koha::Exceptions::Plugin::UpgradeDied->throw( plugin_class => $class ); |
78 |
}; |
66 |
} |
79 |
} |
67 |
} elsif ( $plugin_version ne $database_version ) { |
80 |
} elsif ( $plugin_version ne $database_version ) { |
68 |
$self->store_data({ '__INSTALLED_VERSION__' => $plugin_version }); |
81 |
$self->store_data({ '__INSTALLED_VERSION__' => $plugin_version }); |
69 |
- |
|
|