Bugzilla – Attachment 122324 Details for
Bug 25078
Update DB process - wrap each DBRev inside a transaction and better error handling
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25078: Re-introduce NewVersion
Bug-25078-Re-introduce-NewVersion.patch (text/plain), 8.50 KB, created by
Martin Renvoize (ashimema)
on 2021-06-23 11:18:57 UTC
(
hide
)
Description:
Bug 25078: Re-introduce NewVersion
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-06-23 11:18:57 UTC
Size:
8.50 KB
patch
obsolete
>From 3828eebe04a542f58b7063b825bdd5a736fa4ec4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 15 Jun 2021 11:38:51 +0200 >Subject: [PATCH] Bug 25078: Re-introduce NewVersion > >This is ugly, we re-add the code we removed in the previous patch. > >We need to continue supporting "old" versions. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Installer.pm | 36 +++++++++++++---- > installer/install.pl | 39 +++++++++++++++++-- > .../prog/en/modules/installer/step3.tt | 34 +++++++++++++++- > 3 files changed, 96 insertions(+), 13 deletions(-) > >diff --git a/C4/Installer.pm b/C4/Installer.pm >index 9c01d653de..cd563e2f27 100644 >--- a/C4/Installer.pm >+++ b/C4/Installer.pm >@@ -32,7 +32,7 @@ use vars qw(@ISA @EXPORT); > BEGIN { > require Exporter; > @ISA = qw( Exporter ); >- push @EXPORT, qw( primary_key_exists foreign_key_exists index_exists column_exists TableExists TransformToNum CheckVersion sanitize_zero_date update get_db_entries ); >+ push @EXPORT, qw( primary_key_exists foreign_key_exists index_exists column_exists TableExists TransformToNum CheckVersion NewVersion SetVersion sanitize_zero_date update get_db_entries ); > }; > > =head1 NAME >@@ -763,7 +763,11 @@ sub output_version { > my $DBversion = $db_entry->{version}; > my $bug_number = $db_entry->{bug_number}; > my $time = $db_entry->{time}; >- my $done = $db_entry->{done} ? "done" : "failed"; >+ my $done = defined $db_entry->{done} >+ ? $db_entry->{done} >+ ? " done" >+ : " failed" >+ : ""; # For old versions, we don't know if we succeed or failed > > unless ( ref($descriptions) ) { > $descriptions = [ $descriptions ]; >@@ -775,17 +779,17 @@ sub output_version { > if ( @$descriptions > 1 ) { > if ( $first ) { > unless ( $bug_number ) { >- push @output, sprintf "Upgrade to %s %s [%s]:", $DBversion, $done, $time; >+ push @output, sprintf "Upgrade to %s%s [%s]:", $DBversion, $done, $time; > } else { >- push @output, sprintf "Upgrade to %s %s [%s]: Bug %5s", $DBversion, $done, $time, $bug_number; >+ push @output, sprintf "Upgrade to %s%s [%s]: Bug %5s", $DBversion, $done, $time, $bug_number; > } > } > push @output, sprintf "\t\t\t\t\t\t - %s", $description; > } else { > unless ( $bug_number ) { >- push @output, sprintf "Upgrade to %s %s [%s]: %s", $DBversion, $done, $time, $description; >+ push @output, sprintf "Upgrade to %s%s [%s]: %s", $DBversion, $done, $time, $description; > } else { >- push @output, sprintf "Upgrade to %s %s [%s]: Bug %5s - %s", $DBversion, $done, $time, $bug_number, $description; >+ push @output, sprintf "Upgrade to %s%s [%s]: Bug %5s - %s", $DBversion, $done, $time, $bug_number, $description; > } > } > $first = 0; >@@ -861,8 +865,26 @@ sub SetVersion { > C4::Context::clear_syspref_cache(); # invalidate cached preferences > } > >+# DEPRECATED Don't use it! >+# Used for compatibility with older versions (from updatedatabase.pl) > sub NewVersion { >- # void FIXME replace me >+ my ( $DBversion, $bug_number, $descriptions ) = @_; >+ >+ SetVersion($DBversion); >+ >+ unless ( ref($descriptions) ) { >+ $descriptions = [ $descriptions ]; >+ } >+ >+ my $output = output_version( { >+ bug_number => $bug_number, >+ description => $descriptions, >+ version => $DBversion, >+ time => POSIX::strftime( "%H:%M:%S", localtime ), >+ }); >+ >+ say join "\n", @$output; >+ > } > > =head2 CheckVersion >diff --git a/installer/install.pl b/installer/install.pl >index 7e3626c812..a00e832e2d 100755 >--- a/installer/install.pl >+++ b/installer/install.pl >@@ -393,14 +393,45 @@ elsif ( $step && $step == 3 ) { > chk_log( $logdir, "updatedatabase-error_$filename_suffix" ) > ); > >- my $updatedatabase_path = C4::Context->config("intranetdir") >- . "/installer/data/$info{dbms}/updatedatabase.pl"; >+ my $cmd = C4::Context->config("intranetdir") >+ . "/installer/data/$info{dbms}/updatedatabase.pl >> $logfilepath 2>> $logfilepath_errors"; >+ >+ system( $cmd ); >+ >+ my $fh; >+ open( $fh, "<:encoding(utf-8)", $logfilepath ) >+ or die "Cannot open log file $logfilepath: $!"; >+ my @report = <$fh>; >+ close $fh; >+ if (@report) { >+ $template->param( update_report => >+ [ map { { line => $_ =~ s/\t/  /gr } } split( /\n/, join( '', @report ) ) ] >+ ); >+ $template->param( has_update_succeeds => 1 ); >+ } >+ else { >+ eval { `rm $logfilepath` }; >+ } >+ open( $fh, "<:encoding(utf-8)", $logfilepath_errors ) >+ or die "Cannot open log file $logfilepath_errors: $!"; >+ @report = <$fh>; >+ close $fh; >+ if (@report) { >+ $template->param( update_errors => >+ [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] >+ ); >+ $template->param( has_update_errors => 1 ); >+ warn >+"The following errors were returned while attempting to run the updatedatabase.pl script:\n"; >+ foreach my $line (@report) { warn "$line\n"; } >+ } >+ else { >+ eval { `rm $logfilepath_errors` }; >+ } > > my $db_entries = get_db_entries(); > my $report = update( $db_entries ); > >- # FIXME restore log to logfilepath and logfilepath_errors >- > $template->param( success => $report->{success}, error => $report->{error} ); > > #warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n"; #FIXME restore this >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt >index 04f9976c56..2fca0c40dc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt >@@ -244,8 +244,26 @@ > > [% IF ( updatestructure ) %] > <h2>Updating database structure</h2> >+ [% IF has_update_succeeds || success %] >+ <p>Update report :</p> >+ [% END %] >+ >+ [%# Success for old versions %] >+ [% IF has_update_succeeds %] >+ <ul> >+ [% FOREACH l IN update_report %] >+ [% SET line = l.line %] >+ [% IF line.match('^Upgrade to') %] >+ <li>[% line | $raw %]</li> >+ [% ELSE %] >+ [% line | $raw %]<br/> >+ [% END %] >+ [% END %] >+ </ul> >+ [% END %] >+ >+ [%# Success for new versions %] > [% IF success %] >- <p>Update report:</p> > <ul> > [% FOR s IN success %] > [% FOR o IN s.output %] >@@ -257,6 +275,18 @@ > [% END %] > </ul> > [% END %] >+ >+ [%# Errors for old versions %] >+ [% IF has_update_errors %] >+ <p>Update errors :</p> >+ <ul> >+ [% FOREACH update_error IN update_errors %] >+ <li class="update_error">[% update_error.line | html %]</li> >+ [% END %] >+ </ul> >+ [% END %] >+ >+ [%# Errors for new versions %] > [% IF error %] > <p>Update error :</p> > <ul> >@@ -275,7 +305,7 @@ > [% END %] > </ul> > [% END %] >- [% UNLESS error %] >+ [% UNLESS error OR has_update_errors %] > <p>Everything went okay. Update done.</p> > <p><a href="install.pl?step=3&op=finished" class="btn btn-primary">Continue to log in to Koha</a></p> > [% ELSE %] >-- >2.20.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 25078
:
102521
|
116032
|
116033
|
116034
|
116208
|
116209
|
117084
|
121909
|
121910
|
121911
|
121982
|
121983
|
121984
|
122208
|
122322
|
122323
|
122324
|
122325
|
122326
|
122329
|
122665
|
122666
|
122667
|
122668
|
122669
|
122670
|
122671
|
122679
|
122680
|
122875
|
123356
|
123357
|
123358
|
123359
|
123360
|
123361
|
123362
|
123363
|
123364
|
123365
|
123366
|
123367
|
123850
|
123851
|
123853
|
123937
|
124269