From 90acef7a9b860e70631ff243c21b435a7d081a16 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 1 Jul 2019 11:42:51 -0300 Subject: [PATCH] Bug 23230: Make _version_compare OO context aware On using _version_compare in plugins development, it would be nice if it was able to be called as an object method. This way we don't need to fully qualify it like this: Koha::Plugins::Base::_version_compare and we can do $self->_version_compare instead. This patch implements this behavior change. It is backwards compatible so plugins using the 'old way' don't break. To test: - Apply the unit tests patch - Run: $ kshell k$ prove t/db_dependent/Plugins.t => FAIL: Tests fail - Apply this patch - Run: k$ prove t/db_dependent/Plugins.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Mark Tompsett Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- Koha/Plugins/Base.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Koha/Plugins/Base.pm b/Koha/Plugins/Base.pm index 04fd4858f7..059c6730f3 100644 --- a/Koha/Plugins/Base.pm +++ b/Koha/Plugins/Base.pm @@ -265,8 +265,14 @@ if ( _version_compare( '2.6.26', '2.6.0' ) == 1 ) { =cut sub _version_compare { - my $ver1 = shift || 0; - my $ver2 = shift || 0; + my @args = @_; + + if ( $args[0]->isa('Koha::Plugins::Base') ) { + shift @args; + } + + my $ver1 = shift @args || 0; + my $ver2 = shift @args || 0; my @v1 = split /[.+:~-]/, $ver1; my @v2 = split /[.+:~-]/, $ver2; -- 2.11.4.GIT