From 8c8055269270af43c92c10eeff96ab74fd03f0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Mon, 14 Apr 2025 16:09:34 -0300 Subject: [PATCH] Bug 39632: Make plugin install and upgrade errors more useful This patch makes the install and upgrade process for plugins to add the newly added extra parameters to the thrown exceptions. This is covered by the tests To test: 1. Apply this patch 2. Run: $ ktd --shell k$ prove -r t/Koha/Exceptions.t \ t/db_dependent/Koha/Plugins => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Brendan Gallagher --- Koha/Plugins/Base.pm | 4 ++-- t/db_dependent/Koha/Plugins/Broken.t | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Koha/Plugins/Base.pm b/Koha/Plugins/Base.pm index 75c628e53d..42f5800e1b 100644 --- a/Koha/Plugins/Base.pm +++ b/Koha/Plugins/Base.pm @@ -62,7 +62,7 @@ sub new { warn "Plugin $class failed during installation!"; } } catch { - Koha::Exceptions::Plugin::InstallDied->throw( plugin_class => $class ); + Koha::Exceptions::Plugin::InstallDied->throw( plugin_class => $class, install_error => "$_" ); }; } elsif ( $self->can('upgrade') ) { if ( _version_compare( $plugin_version, $database_version ) == 1 ) { @@ -73,7 +73,7 @@ sub new { warn "Plugin $class failed during upgrade!"; } } catch { - Koha::Exceptions::Plugin::UpgradeDied->throw( plugin_class => $class ); + Koha::Exceptions::Plugin::UpgradeDied->throw( plugin_class => $class, upgrade_error => "$_" ); }; } } elsif ( $plugin_version ne $database_version ) { diff --git a/t/db_dependent/Koha/Plugins/Broken.t b/t/db_dependent/Koha/Plugins/Broken.t index 8db1861000..dab439b5b3 100755 --- a/t/db_dependent/Koha/Plugins/Broken.t +++ b/t/db_dependent/Koha/Plugins/Broken.t @@ -37,12 +37,13 @@ $schema->storage->txn_begin; t::lib::Mocks::mock_config( 'enable_plugins', 1 ); -my $plugins = Koha::Plugins->new; +my $plugins = Koha::Plugins->new; +my $error_string = 'Why Liz? WHY?'; warnings_are { $plugins->InstallPlugins; } [ - "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", - "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" + "Calling 'install' died for plugin Koha::Plugin::BrokenInstall: $error_string", + "Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade: $error_string" ]; $schema->storage->txn_begin; -- 2.39.5