Bugzilla – Attachment 124856 Details for
Bug 29008
Warning when checking Koha version in plugins
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29008: Avoid warning when checking Koha version in plugins
Bug-29008-Avoid-warning-when-checking-Koha-version.patch (text/plain), 4.49 KB, created by
Fridolin Somers
on 2021-09-14 09:19:55 UTC
(
hide
)
Description:
Bug 29008: Avoid warning when checking Koha version in plugins
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2021-09-14 09:19:55 UTC
Size:
4.49 KB
patch
obsolete
>From ac78ea51194ead8e179ebafd91f2d3da2e70957c Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Mon, 13 Sep 2021 20:31:24 -1000 >Subject: [PATCH] Bug 29008: Avoid warning when checking Koha version in > plugins > >In Koha plugins home page, each plugin min/max version is compared with actual Koha version. > >This uses metadatas assuming there are numbers, like 18.11 or 20.1100000. > >But source code version is actually YY.MM.XX.YYY.ZZZ. >We sometimes find it in plugins, for examle : >https://github.com/thekesolutions/koha-plugin-bibliocommons/blob/c2da98f1bda450452ad687e5623f45939a967bdf/Koha/Plugin/Com/Theke/BiblioCommons.pm#L31 >https://github.com/KohaSuomi/koha-plugin-sms-send-link-mobility-driver/blob/master/Koha/Plugin/Fi/KohaSuomi/SMSSendLinkMobilityDriver.pm#L22 > >This generates warning : >Argument "18.11.01" isn't numeric in numeric lt (<) at /home/koha/src/Koha/Plugins/Base.pm line 377.: src/plugins/plugins-home.pl > >We should allow this syntax in plugins metadatas. > >Test plan : >1) Install a Koha plugin with minimum_version containing 3 dots : > for example 18.11.01.001 >2) Go to plugins home page >3) Check there is no warning >4) Install a plugin with minimum_version higher than current Koha version >5) Check in plugins table the warning appears >6) Install a plugin with maximum_version lower than current Koha version >7) Check in plugins table the warning appears >--- > Koha/Plugins/Base.pm | 24 +++++++++++++++++++ > .../prog/en/modules/plugins/plugins-home.tt | 4 ++-- > plugins/plugins-home.pl | 1 - > 3 files changed, 26 insertions(+), 3 deletions(-) > >diff --git a/Koha/Plugins/Base.pm b/Koha/Plugins/Base.pm >index e935e74a18..269a64e896 100644 >--- a/Koha/Plugins/Base.pm >+++ b/Koha/Plugins/Base.pm >@@ -369,6 +369,30 @@ sub disable { > return $self; > } > >+sub is_for_newer_koha { >+ my ($self) = @_; >+ my $actual_version = Koha::version; >+ my $min_version = $self->get_metadata->{minimum_version}; >+ return 0 unless $min_version; >+ return ( _version_to_number($actual_version) < _version_to_number($min_version) ) ? 1 : 0; >+} >+ >+sub is_for_older_koha { >+ my ($self) = @_; >+ my $actual_version = Koha::version; >+ my $max_version = $self->get_metadata->{maximum_version}; >+ return 0 unless $max_version; >+ return ( _version_to_number($actual_version) > _version_to_number($max_version) ) ? 1 : 0; >+} >+ >+sub _version_to_number { >+ my $koha_version = shift; >+ return 0 unless defined($koha_version); >+ # Version in metadata may be 18.11, 20.05.02, 21.05.00.006 ... >+ $koha_version =~ s/(.*\..*)\.?(.*)\.?(.*)/$1$2$3/; >+ return $koha_version; >+} >+ > 1; > __END__ > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt >index 55ff28663a..661f14942b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/plugins/plugins-home.tt >@@ -151,13 +151,13 @@ > <td> > [% plugin.metadata.description | html %] > >- [% IF ( plugin.metadata.minimum_version && koha_version < plugin.metadata.minimum_version ) %] >+ [% IF ( plugin.is_for_newer_koha ) %] > <div class="dialog alert"> > Warning: This report was written for a newer version of Koha. Run at your own risk. > </div> > [% END %] > >- [% IF ( plugin.metadata.maximum_version && koha_version > plugin.metadata.maximum_version ) %] >+ [% IF ( plugin.is_for_older_koha ) %] > <div class="dialog alert"> > Warning: This plugin was written for an older version of Koha. Run at your own risk. > </div> >diff --git a/plugins/plugins-home.pl b/plugins/plugins-home.pl >index da892ba1f2..70bc558594 100755 >--- a/plugins/plugins-home.pl >+++ b/plugins/plugins-home.pl >@@ -46,7 +46,6 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > if ($plugins_enabled) { > > $template->param( >- koha_version => C4::Context->preference("Version"), > method => $method, > ); > >-- >2.32.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29008
:
124856
|
124857
|
124858
|
124859
|
140614
|
140615
|
140616