From 016e66c6f25fbe3b648bcb8dad8d59f80d11b992 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Sun, 6 Nov 2011 09:36:52 +0100 Subject: [PATCH] Bug 7184 raise mySQL error if debug is set Before this patch, if a mySQL occured in Koha (any error), then the user was seeing nothing. With this patch, if DEBUG is set in Koha VirtualHost, any mySQL error will make Koha die and display the SQL error Step to test: === BEFORE PATCH === go anywhere, and change a mySQL statement to make it invalid. Launch a page using the SQL you've made wrong, you'll see nothing, except you won't see the expected results === AFTER PATCH === Modify koha-httpd.conf, and add the following line, in the virtualhost (if it does not already exist) SetEnv DEBUG 1 restart/reload Apache Launch the same page, you'll get a Perl statement saying something like: DBD::mysql::st execute failed: <> at <> --- C4/Context.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Context.pm b/C4/Context.pm index 85d1c1870a..c63641cc63 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -690,7 +690,7 @@ sub _new_dbh 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) or die $DBI::errstr; + $db_user, $db_passwd, {'RaiseError' => $ENV{DEBUG}?1:0 }) or die $DBI::errstr; my $tz = $ENV{TZ}; if ( $db_driver eq 'mysql' ) { # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config. -- 2.39.5