From 15e4850d423cfc5ad87ac44af127a484f2fec923 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 30 Nov 2020 15:30:45 +0100 Subject: [PATCH] Bug 25026: Turn on RaiseError This is a follow-up for bug 22001. The patch "Bug 22001: Set unsafe only if RaiseError is not set" proved that unsafe => 1 and RaiseError => 0 was wrong. We should move forward and turn RaiseError for the UI, and... see what's happening. The change goes to the right direction, but we need to know how big is the task to have a stable release with these parameters correctly set. We will have a lot of fun once this patch is pushed! :) Test plan: 0. Does not apply the patch 1. Add, somewhere in mainpage.pl C4::Acquisition::NewBasket(); 2. restart_all 3. Hit the mainpage => Hum... nothing happens! However there is an error in the logs DBI Exception: DBD::mysql::db do failed: Column 'booksellerid' cannot be null No basket has been created! 4. Apply the patch, restart_all 5. Hit the mainpage => Here we go, there was something wrong and the user is aware of that! Signed-off-by: Victor Grousset/tuxayo --- Koha/Database.pm | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Koha/Database.pm b/Koha/Database.pm index f000a78494..f460618b68 100644 --- a/Koha/Database.pm +++ b/Koha/Database.pm @@ -90,20 +90,14 @@ sub _new_schema { $tz_query = qq(SET TIME ZONE = "$tz") if $tz; } - my $RaiseError = ( - $ENV{DEBUG} - || $ENV{KOHA_TESTING} - || exists $ENV{_} && $ENV{_} =~ m|prove| - ) ? 1 : 0; my $schema = Koha::Schema->connect( { dsn => "dbi:$db_driver:database=$db_name;host=$db_host;port=$db_port".($tls_options? $tls_options : ""), user => $db_user, password => $db_passwd, %encoding_attr, - RaiseError => $RaiseError, + RaiseError => 1, PrintError => 1, - unsafe => !$RaiseError, quote_names => 1, auto_savepoint => 1, on_connect_do => [ @@ -116,7 +110,6 @@ sub _new_schema { my $dbh = $schema->storage->dbh; eval { - $dbh->{RaiseError} = 1; if ( $ENV{KOHA_DB_DO_NOT_RAISE_OR_PRINT_ERROR} ) { $dbh->{RaiseError} = 0; $dbh->{PrintError} = 0; @@ -124,7 +117,8 @@ sub _new_schema { $dbh->do(q| SELECT * FROM systempreferences WHERE 1 = 0 | ); - $dbh->{RaiseError} = $RaiseError + $dbh->{RaiseError} = 1; + $dbh->{PrintError} = 1; }; $dbh->{RaiseError} = 0 if $@; -- 2.29.2