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 <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-11-30 15:30:45 +01:00
parent 91ddddd8eb
commit de14c96249

View file

@ -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 $@;