Bugzilla – Attachment 145504 Details for
Bug 32687
About may list version of SQL client in container, not actual server
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32687: Get server version in Context::get_versions
Bug-32687-Get-server-version-in-Contextgetversions.patch (text/plain), 3.17 KB, created by
Marcel de Rooy
on 2023-01-20 09:40:42 UTC
(
hide
)
Description:
Bug 32687: Get server version in Context::get_versions
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-01-20 09:40:42 UTC
Size:
3.17 KB
patch
obsolete
>From 916bf018f86c5ddac4ff40bce331a1389875ec0d Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 20 Jan 2023 09:34:57 +0000 >Subject: [PATCH] Bug 32687: Get server version in Context::get_versions >Content-Type: text/plain; charset=utf-8 > >Test plan: >Run t/db_dependent/Context.t >Check About/Server information/MySQL version. >--- > C4/Context.pm | 9 +++++++-- > t/db_dependent/Context.t | 24 +++++++++++++++++++++++- > 2 files changed, 30 insertions(+), 3 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 1aec1232f3..3819529dc2 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -820,20 +820,25 @@ Gets various version info, for core Koha packages, Currently called from carp ha > > # A little example sub to show more debugging info for CGI::Carp > sub get_versions { >- my %versions; >+ my ( %versions, $mysqlVersion ); > $versions{kohaVersion} = Koha::version(); > $versions{kohaDbVersion} = C4::Context->preference('version'); > $versions{osVersion} = join(" ", POSIX::uname()); > $versions{perlVersion} = $]; >+ >+ my $dbh = C4::Context->dbh; >+ $mysqlVersion = $dbh->get_info(18) if $dbh; # SQL_DBMS_VER >+ > { > no warnings qw(exec); # suppress warnings if unable to find a program in $PATH >- $versions{mysqlVersion} = `mysql -V`; >+ $mysqlVersion ||= `mysql -V`; # fallback to sql client version? > $versions{apacheVersion} = (`apache2ctl -v`)[0]; > $versions{apacheVersion} = `httpd -v` unless $versions{apacheVersion} ; > $versions{apacheVersion} = `httpd2 -v` unless $versions{apacheVersion} ; > $versions{apacheVersion} = `apache2 -v` unless $versions{apacheVersion} ; > $versions{apacheVersion} = `/usr/sbin/apache2 -v` unless $versions{apacheVersion} ; > } >+ $versions{mysqlVersion} = $mysqlVersion; > return %versions; > } > >diff --git a/t/db_dependent/Context.t b/t/db_dependent/Context.t >index 88539fe34b..67587b4798 100755 >--- a/t/db_dependent/Context.t >+++ b/t/db_dependent/Context.t >@@ -16,7 +16,8 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 4; >+use Test::More tests => 5; >+use Test::MockModule; > > use C4::Context; > use Koha::Database; >@@ -147,3 +148,24 @@ subtest 'Zconn' => sub { > $oConnection = C4::Context->Zconn('biblioserver', 1); > is($oConnection->option('async'), 1, "ZOOM connection is asynchronous"); > }; >+ >+subtest 'get_versions' => sub { >+ plan tests => 2; >+ >+ my $dbh = C4::Context->dbh; >+ my $mod = Test::MockModule->new( 'C4::Context' ); >+ my $no_dbh; >+ $mod->mock( 'dbh', sub { return $no_dbh ? undef : $dbh; } ); >+ >+ my $client = `mysql -V`; >+ my $server = ( C4::Context->dbh->selectrow_array("SHOW VARIABLES LIKE 'version'") )[1]; >+ my $server_version; >+ if( $server =~ /(\d+(\.\d+)+)/ ) { >+ $server_version = $1; >+ $server_version =~ s/\./\\./g; >+ } >+ my $v; >+ like( $v = { C4::Context::get_versions }->{mysqlVersion}, qr/$server_version/, "Server version $v found" ); >+ $no_dbh = 1; >+ is( $v = { C4::Context::get_versions }->{mysqlVersion}, $client, "Client version $v found" ); >+}; >-- >2.30.2
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 32687
:
145504
|
145563
|
147211