Bugzilla – Attachment 51680 Details for
Bug 13669
Web installer fails to load sample data on MySQL 5.6+
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 13669: Catch the errors to have them to the logs
SIGNED-OFF-Bug-13669-Catch-the-errors-to-have-them.patch (text/plain), 2.38 KB, created by
Bernardo Gonzalez Kriegel
on 2016-05-21 12:14:50 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 13669: Catch the errors to have them to the logs
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2016-05-21 12:14:50 UTC
Size:
2.38 KB
patch
obsolete
>From 121e5685831110520411c5b5708ea955205f1311 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sat, 21 May 2016 09:04:27 +0100 >Subject: [PATCH] [SIGNED-OFF] Bug 13669: Catch the errors to have them to the > logs > >This patch redirect STDERR to a variable to retrieve the errors raised >by the DBMS when loading a sql file, it could be useful to debug errors. > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >It's better of course, trying to load a failed fiel >it outputs mysl errors >DBD::mysql::st execute failed: You have an error in your SQL syntax... >No errors >--- > C4/Installer.pm | 37 ++++++++++++++++++------------------- > 1 file changed, 18 insertions(+), 19 deletions(-) > >diff --git a/C4/Installer.pm b/C4/Installer.pm >index 9ffc396..1e6768e 100644 >--- a/C4/Installer.pm >+++ b/C4/Installer.pm >@@ -412,18 +412,11 @@ sub set_version_syspref { > > my $error = $installer->load_sql($filename); > >-Runs a the specified SQL using the DB's command-line >-SQL tool, and returns any strings sent to STDERR >-by the command-line tool. >+Runs a the specified SQL file using a sql loader DBIx::RunSQL >+Returns any strings sent to STDERR > >-B<FIXME:> there has been a long-standing desire to >-replace this with an SQL loader that goes >-through DBI; partly for portability issues >-and partly to improve error handling. >- >-B<FIXME:> even using the command-line loader, some more >-basic error handling should be added - deal >-with missing files, e.g. >+# FIXME This should be improved: sometimes the caller and load_sql warn the same >+error. > > =cut > >@@ -434,17 +427,23 @@ sub load_sql { > > my $dbh = $self->{ dbh }; > >- eval { >- DBIx::RunSQL->run_sql_file( >- dbh => $dbh, >- sql => $filename, >- ); >+ my $dup_stderr; >+ do { >+ local *STDERR; >+ open STDERR, ">>", \$dup_stderr; >+ >+ eval { >+ DBIx::RunSQL->run_sql_file( >+ dbh => $dbh, >+ sql => $filename, >+ ); >+ }; > }; > # errors thrown while loading installer data should be logged >- if( $@ ) { >+ if( $dup_stderr ) { > warn "C4::Installer::load_sql returned the following errors while attempting to load $filename:\n"; >- warn "$@"; >- $error = "Error attempting to load $filename:\n$@"; >+ $error = $dup_stderr; >+ > } > > return $error; >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13669
:
51596
|
51597
|
51598
|
51599
|
51600
|
51601
|
51607
|
51608
|
51610
|
51611
|
51612
|
51671
|
51672
|
51680
|
51681
|
51682
|
51683
|
51684
|
51685
|
51736
|
51738
|
51746