From 5681c4e6e3bcce210923eeb060b323d396f32569 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 17 Mar 2021 10:44:31 -0400 Subject: [PATCH] Bug 31684: Plugin versions starting with a "v" cause unnecessary warnings Content-Type: text/plain; charset=utf-8 Our code assumes that plugin version will be purely numeric ( e.g. 1.2.3 ) but many plugin authors ( including myself ) use the format "v1.2.3". This causes warnings as we use a numeric comparison on the version numbers. It could make sense to check for and strip any v's from the beginning of the version. Test Plan: 1) Apply the first patch to set the test plugin's version to v1.01 2) prove t/db_dependent/Koha/Plugins/Plugins.t 3) Note the warnings and test failures 4) Apply this patch 5) prove t/db_dependent/Koha/Plugins/Plugins.t 6) All tests pass! Signed-off-by: David Nind Signed-off-by: Marcel de Rooy --- Koha/Plugins/Base.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Koha/Plugins/Base.pm b/Koha/Plugins/Base.pm index 92ce7714bd..487a3dc5e2 100644 --- a/Koha/Plugins/Base.pm +++ b/Koha/Plugins/Base.pm @@ -326,6 +326,11 @@ sub _version_compare { # 0.0.0 <=> 0.2.1 = -1 push( @v1, 0 ) unless defined( $v1[$i] ); push( @v2, 0 ) unless defined( $v2[$i] ); + + # Strip letters before comparing, supresses 'Argument "v1" isn't numeric in int' warning + $v1[$i] =~ s/^v//g; + $v2[$i] =~ s/^v//g; + if ( int( $v1[$i] ) > int( $v2[$i] ) ) { return 1; } -- 2.30.2