@@ -, +, @@
connections.
-----------------
- BUSINESS CASE -
-----------------
------------
- SOLUTION -
------------
-------------
- TEST PLAN -
-------------
by default /var/run/mysqld/mysqld.sock .
or create the xml-entry /var/run/mysqld/mysqld.sock
You can still use Koha normally, but it is recommended to fix bad socket ASAP.
---
C4/Context.pm | 19 ++++++++++++++++---
etc/koha-conf.xml | 1 +
2 files changed, 17 insertions(+), 3 deletions(-)
--- a/C4/Context.pm
+++ a/C4/Context.pm
@@ -806,9 +806,22 @@ sub _new_dbh
my $db_port = $context->config("port") || '';
my $db_user = $context->config("user");
my $db_passwd = $context->config("pass");
- # MJR added or die here, as we can't work without dbh
- my $dbh = DBI->connect("DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",
- $db_user, $db_passwd, {'RaiseError' => $ENV{DEBUG}?1:0 }) or die $DBI::errstr;
+ my $db_mysql_socket = $context->config("mysql_socket") || '';
+
+ my $dbh;
+ #if a unix socket is given use that instead of TCP (as it is way faster!) ONLY Mysql-derivatives
+ # Instead of dying, just warn about the error because we can fall back to a TCP-connection.
+ if ($db_mysql_socket && ($db_driver =~ /mysql/i || $db_driver =~ /mariadb/i)) {
+ # MJR added or die here, as we can't work without dbh
+ $dbh = DBI->connect("DBI:$db_driver:dbname=$db_name;mysql_socket=$db_mysql_socket",
+ $db_user, $db_passwd, {'RaiseError' => $ENV{DEBUG}?1:0 }) or warn $DBI::errstr;
+ }
+ #Try making a TCP connection
+ if ((! defined ($dbh))) {
+ # MJR added or die here, as we can't work without dbh
+ $dbh = DBI->connect("DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",
+ $db_user, $db_passwd, {'RaiseError' => $ENV{DEBUG}?1:0 }) or die $DBI::errstr;
+ }
# Check for the existence of a systempreference table; if we don't have this, we don't
# have a valid database and should not set RaiseError in order to allow the installer
--- a/etc/koha-conf.xml
+++ a/etc/koha-conf.xml
@@ -271,6 +271,7 @@ __PAZPAR2_TOGGLE_XML_POST__
__DB_NAME__
__DB_HOST__
__DB_PORT__
+
__DB_USER__
__DB_PASS__
biblios
--