Bug 31684: Plugin versions starting with a "v" cause unnecessary warnings

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 <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit fd51a238c8)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Kyle Hall 2021-03-17 10:44:31 -04:00 committed by Lucas Gass
parent 251379247b
commit a88895d0b8

View file

@ -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;
}