From ece0c4d8a789a9399293f15a788d3cb3fbb06ea8 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Wed, 6 Apr 2022 08:38:00 -0400 Subject: [PATCH] Bug 30468: koha-mysql does not honor Koha's timezone setting If I run a query like "SELECT NOW()" from a koha report, I will get a different answer than if I had run it from koha-mysql. In Koha, we set the timezone for each database connection. However, koha-mysql does not do this, so instead we are left using the default timezone of the database. Test Plan: 1) Set your time zone to something other than the database time zone 2) run "SELECT NOW()" using debian/scripts/koha-mysql *not* /usr/sbin/koha-mysql 3) Note you get the database timezone's current time 4) Apply this patch 5) Repeat step 2 6) Now you get the correct time! --- debian/scripts/koha-mysql | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/debian/scripts/koha-mysql b/debian/scripts/koha-mysql index 4a09e51c77..d10055ab3a 100755 --- a/debian/scripts/koha-mysql +++ b/debian/scripts/koha-mysql @@ -17,8 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -set -e - umask 0077 # include helper functions @@ -55,6 +53,15 @@ mysqldb="$( xmlstarlet sel -t -v 'yazgfs/config/database' $kohaconfig )" mysqluser="$( xmlstarlet sel -t -v 'yazgfs/config/user' $kohaconfig )" mysqlpass="$( xmlstarlet sel -t -v 'yazgfs/config/pass' $kohaconfig )" -mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpass" \ +mysqltz="$( xmlstarlet sel -t -v 'yazgfs/config/timezone' $kohaconfig )" +if [ $? -eq 0 ] +then + echo "Using time zone $mysqltz" + mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpass" --init-command="SET time_zone = '$mysqltz'" \ + "$mysqldb" "${@}" +else + echo "No time zone set for Koha, using database time zone." + mysql --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpass" \ "$mysqldb" "${@}" +fi -- 2.30.2