Bug 14334 removed some of the RaiseError flags that existed in tests. It should always be set in tests, just in case :) Moreover, patches of bug 14334 could hide a regression, if we have a test catching a crash (using eval), it will no longer explode.
Created attachment 83230 [details] [review] Bug 22001: Remove the RaiseError occurrences from tests Unless it is needed! Also remove $dbh when not used later.
Created attachment 83231 [details] [review] Bug 22001: Add tests
Created attachment 83232 [details] [review] Bug 22001: Enable RaiseError for tests
Created attachment 98910 [details] [review] Bug 22001: Remove the RaiseError occurrences from tests Unless it is needed! Also remove $dbh when not used later.
Created attachment 98911 [details] [review] Bug 22001: Add tests
Created attachment 98912 [details] [review] Bug 22001: Enable RaiseError for tests
Created attachment 99589 [details] [review] Bug 22001: Remove the RaiseError occurrences from tests Unless it is needed! Also remove $dbh when not used later. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 99590 [details] [review] Bug 22001: Add tests Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 99591 [details] [review] Bug 22001: Enable RaiseError for tests Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Works as expected.. sorry I didn't spot this one earlier :(
I'm happy with this one.. it's important for us to see the errors being thrown.. Passing QA
Nice work everyone! Pushed to master for 20.05
Created attachment 101989 [details] [review] Bug 22002: (RM follow-up) Allow RaiseError tests in Reports/Guided.t
Created attachment 101990 [details] [review] Bug 22001: (RM follow-up) Allow RaiseError tests in Reports/Guided.t
Created attachment 101991 [details] [review] Bug 22001: Fix Reports/Guided.t tests
Created attachment 102070 [details] [review] Bug 22001: Fix Object.t - handle correct RaiseError and PrintError
Final followup pushed.
Created attachment 102140 [details] [review] Bug 22001: Set unsafe only if RaiseError is not set Sooooo.... That was tricky, and the solution looks trivial. However it's not. We have unsafe set for "historical reason". Having it on when RaiseError is on have the effect of overwritting the DBIC error handler. The problem is: t/db_dependent/Circulation/MarkIssueReturned.t (and other tests) is failing with: # expecting: Koha::Exceptions::Object::BadValue # found: DBIx::Class::Exception ({UNKNOWN}: Can't locate object method "rethrow" via package "DBD::mysql::st execute failed: Incorrect datetime value: 'bad_date' for column 'returndate' at row 1 [for Statement "UPDATE `issues` SET `returndate` = ? WHERE ( `issue_id` = ? )" with ParamValues: 0='bad_date', 1=238] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line In Koha::Object->store, the exception is not a DBIx::Class::Exception object (as we except), but a string (on which we cannot call rethrow). Swithing unsafe off restores the expected behavior. To make sure the UI will not be affected, it is only turned off when RaiseError is set. The situation is still wrong (for UI), from the POD https://metacpan.org/pod/DBIx::Class::Storage::DBI (/unsafe) """ Note that your custom settings can cause Storage to malfunction, especially if you set a HandleError handler that suppresses exceptions and/or disable RaiseError. """ And also https://metacpan.org/release/DBIx-Class/source/lib/DBIx/Class/Storage/DBI.pm#L1531 Many thanks Tomas for the digging exploration! We need to turn RaiseError and remove the unsafe flag, for UI as well, but that should be done at the beginning of a dev cycle.
Created attachment 102147 [details] [review] Bug 22001: Add the DBI error message Using DBIx::Class error handler, we should not hide the error when encapsulating it
Created attachment 102149 [details] [review] Bug 22001: Make the DBD error regex less strict Now the message is looking like DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry
Created attachment 102150 [details] [review] Bug 22001: Fix Koha/Patrons.t The message is only printed once
Created attachment 102151 [details] [review] Bug 22001: execute reports in an eval Otherwise the tests will fail. We will certainly log twice the error when run from the UI, but not a big deal. This definitely needs more attention in a follow-up bug report. We want to raise proper exceptions here.
Created attachment 102152 [details] [review] Bug 22001: Errors are no longer logged by default (!) This is one of the biggest part we will have to deal with when we will switch to DBIC handler for UI as well. The DBI errors will not be logged if we do not deal with them correctly.
enhancement not backported to 19.11.x