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: <<blablabla SQL error>> at <<where the error was raised line <<error line>>
(cherry picked from commit 016e66c6f2)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
Paul Poulain 2011-11-06 09:36:52 +01:00 committed by Chris Nighswonger
parent 916e103dfc
commit 73139544c8
1 changed files with 1 additions and 1 deletions

View File

@ -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.