[Patches] [PATCH] Bug 7184 raise mySQL error if debug is set

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Sun Nov 6 21:40:04 NZDT 2011


From: Paul Poulain <paul.poulain at biblibre.com>
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: <<blablabla SQL error>> at <<where the error was raised line <<error line>>
---
 C4/Context.pm |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/C4/Context.pm b/C4/Context.pm
index 85d1c18..c63641c 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.
-- 
1.7.5.4


More information about the Patches mailing list