From 6c773a891704ee94c0e8159048c3c1aec62986d3 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 25 Jun 2019 09:21:44 +0100 Subject: [PATCH] Bug 23191: (follow-up) Improve output This patch adds a check of what plugins installed before the script run and outputs only those plugins that have been installed for the first time or upgraded during this run. Signed-off-by: Alex Arnaud Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- misc/devel/install_plugins.pl | 39 ++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/misc/devel/install_plugins.pl b/misc/devel/install_plugins.pl index 19ba68dbcc..69dd99e544 100755 --- a/misc/devel/install_plugins.pl +++ b/misc/devel/install_plugins.pl @@ -39,9 +39,18 @@ unless ($plugins_enabled) { exit 1; } -my @plugins = Koha::Plugins->new()->InstallPlugins(); -unless (@plugins) { +my @existing_plugins = Koha::Plugins->new()->GetPlugins({ + all => 1, +}); +my $existing_plugins; +for my $existing_plugin (@existing_plugins) { + $existing_plugins->{ $existing_plugin->{metadata}->{name} } = + $existing_plugin->{metadata}->{version}; +} + +my @installed_plugins = Koha::Plugins->new()->InstallPlugins(); +unless (@installed_plugins) { my $plugins_dir = C4::Context->config("pluginsdir"); if ( ref($plugins_dir) eq 'ARRAY' ) { print "No plugins found\n"; @@ -50,14 +59,30 @@ unless (@plugins) { else { print "No plugins found at $plugins_dir\n"; } + exit 0; } -for my $plugin (@plugins) { - print "Installed " - . $plugin->{metadata}->{name} - . " version " - . $plugin->{metadata}->{version} . "\n"; +for my $installed_plugin (@installed_plugins) { + if ( !exists( $existing_plugins->{ $installed_plugin->{metadata}->{name} } ) + ) + { + print "Installed " + . $installed_plugin->{metadata}->{name} + . " version " + . $installed_plugin->{metadata}->{version} . "\n"; + } + elsif ( $existing_plugins->{ $installed_plugin->{metadata}->{name} } ne + $installed_plugin->{metadata}->{version} ) + { + print "Upgraded " + . $installed_plugin->{metadata}->{name} + . " from version " + . $existing_plugins->{ $installed_plugin->{metadata}->{name} } + . " to version " + . $installed_plugin->{metadata}->{version} . "\n"; + } } +print "All plugins successfully re-initialised\n"; =head1 NAME -- 2.39.5