View | Details | Raw Unified | Return to bug 25078
Collapse All | Expand All

(-)a/C4/Installer.pm (-7 / +29 lines)
Lines 32-38 use vars qw(@ISA @EXPORT); Link Here
32
BEGIN {
32
BEGIN {
33
    require Exporter;
33
    require Exporter;
34
    @ISA = qw( Exporter );
34
    @ISA = qw( Exporter );
35
    push @EXPORT, qw( primary_key_exists foreign_key_exists index_exists column_exists TableExists TransformToNum CheckVersion sanitize_zero_date update get_db_entries );
35
    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 );
36
};
36
};
37
37
38
=head1 NAME
38
=head1 NAME
Lines 763-769 sub output_version { Link Here
763
    my $DBversion = $db_entry->{version};
763
    my $DBversion = $db_entry->{version};
764
    my $bug_number = $db_entry->{bug_number};
764
    my $bug_number = $db_entry->{bug_number};
765
    my $time = $db_entry->{time};
765
    my $time = $db_entry->{time};
766
    my $done = $db_entry->{done} ? "done" : "failed";
766
    my $done = defined $db_entry->{done}
767
                ? $db_entry->{done}
768
                    ? " done"
769
                    : " failed"
770
                : ""; # For old versions, we don't know if we succeed or failed
767
771
768
    unless ( ref($descriptions) ) {
772
    unless ( ref($descriptions) ) {
769
        $descriptions = [ $descriptions ];
773
        $descriptions = [ $descriptions ];
Lines 775-791 sub output_version { Link Here
775
        if ( @$descriptions > 1 ) {
779
        if ( @$descriptions > 1 ) {
776
            if ( $first ) {
780
            if ( $first ) {
777
                unless ( $bug_number ) {
781
                unless ( $bug_number ) {
778
                    push @output, sprintf "Upgrade to %s %s [%s]:", $DBversion, $done, $time;
782
                    push @output, sprintf "Upgrade to %s%s [%s]:", $DBversion, $done, $time;
779
                } else {
783
                } else {
780
                    push @output, sprintf "Upgrade to %s %s [%s]: Bug %5s", $DBversion, $done, $time, $bug_number;
784
                    push @output, sprintf "Upgrade to %s%s [%s]: Bug %5s", $DBversion, $done, $time, $bug_number;
781
                }
785
                }
782
            }
786
            }
783
            push @output, sprintf "\t\t\t\t\t\t   - %s", $description;
787
            push @output, sprintf "\t\t\t\t\t\t   - %s", $description;
784
        } else {
788
        } else {
785
            unless ( $bug_number ) {
789
            unless ( $bug_number ) {
786
                push @output, sprintf "Upgrade to %s %s [%s]: %s", $DBversion, $done, $time, $description;
790
                push @output, sprintf "Upgrade to %s%s [%s]: %s", $DBversion, $done, $time, $description;
787
            } else {
791
            } else {
788
                push @output, sprintf "Upgrade to %s %s [%s]: Bug %5s - %s", $DBversion, $done, $time, $bug_number, $description;
792
                push @output, sprintf "Upgrade to %s%s [%s]: Bug %5s - %s", $DBversion, $done, $time, $bug_number, $description;
789
            }
793
            }
790
        }
794
        }
791
        $first = 0;
795
        $first = 0;
Lines 861-868 sub SetVersion { Link Here
861
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
865
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
862
}
866
}
863
867
868
# DEPRECATED Don't use it!
869
# Used for compatibility with older versions (from updatedatabase.pl)
864
sub NewVersion {
870
sub NewVersion {
865
    # void FIXME replace me
871
    my ( $DBversion, $bug_number, $descriptions ) = @_;
872
873
    SetVersion($DBversion);
874
875
    unless ( ref($descriptions) ) {
876
        $descriptions = [ $descriptions ];
877
    }
878
879
    my $output = output_version( {
880
            bug_number  => $bug_number,
881
            description => $descriptions,
882
            version     => $DBversion,
883
            time        => POSIX::strftime( "%H:%M:%S", localtime ),
884
    });
885
886
    say join "\n", @$output;
887
866
}
888
}
867
889
868
=head2 CheckVersion
890
=head2 CheckVersion
(-)a/installer/install.pl (-4 / +35 lines)
Lines 394-407 elsif ( $step && $step == 3 ) { Link Here
394
            chk_log( $logdir, "updatedatabase-error_$filename_suffix" )
394
            chk_log( $logdir, "updatedatabase-error_$filename_suffix" )
395
        );
395
        );
396
396
397
        my $updatedatabase_path = C4::Context->config("intranetdir")
397
        my $cmd = C4::Context->config("intranetdir")
398
          . "/installer/data/$info{dbms}/updatedatabase.pl";
398
          . "/installer/data/$info{dbms}/updatedatabase.pl >> $logfilepath 2>> $logfilepath_errors";
399
400
        system( $cmd );
401
402
        my $fh;
403
        open( $fh, "<:encoding(utf-8)", $logfilepath )
404
          or die "Cannot open log file $logfilepath: $!";
405
        my @report = <$fh>;
406
        close $fh;
407
        if (@report) {
408
            $template->param( update_report =>
409
                  [ map { { line => $_ =~ s/\t/&emsp;&emsp;/gr } } split( /\n/, join( '', @report ) ) ]
410
            );
411
            $template->param( has_update_succeeds => 1 );
412
        }
413
        else {
414
            eval { `rm $logfilepath` };
415
        }
416
        open( $fh, "<:encoding(utf-8)", $logfilepath_errors )
417
          or die "Cannot open log file $logfilepath_errors: $!";
418
        @report = <$fh>;
419
        close $fh;
420
        if (@report) {
421
            $template->param( update_errors =>
422
                  [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ]
423
            );
424
            $template->param( has_update_errors => 1 );
425
            warn
426
"The following errors were returned while attempting to run the updatedatabase.pl script:\n";
427
            foreach my $line (@report) { warn "$line\n"; }
428
        }
429
        else {
430
            eval { `rm $logfilepath_errors` };
431
        }
399
432
400
        my $db_entries = get_db_entries();
433
        my $db_entries = get_db_entries();
401
        my $report = update( $db_entries );
434
        my $report = update( $db_entries );
402
435
403
        # FIXME restore log to logfilepath and logfilepath_errors
404
405
        $template->param( success => $report->{success}, error => $report->{error} );
436
        $template->param( success => $report->{success}, error => $report->{error} );
406
437
407
        #warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n"; #FIXME restore this
438
        #warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n"; #FIXME restore this
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt (-3 / +32 lines)
Lines 244-251 Link Here
244
244
245
                [% IF ( updatestructure ) %]
245
                [% IF ( updatestructure ) %]
246
                    <h2>Updating database structure</h2>
246
                    <h2>Updating database structure</h2>
247
                    [% IF has_update_succeeds || success %]
248
                        <p>Update report :</p>
249
                    [% END %]
250
251
                    [%# Success for old versions %]
252
                    [% IF has_update_succeeds %]
253
                        <ul>
254
                            [% FOREACH l IN update_report %]
255
                                [% SET line = l.line %]
256
                                [% IF line.match('^Upgrade to') %]
257
                                    <li>[% line | $raw %]</li>
258
                                [% ELSE %]
259
                                    [% line | $raw %]<br/>
260
                                [% END %]
261
                            [% END %]
262
                        </ul>
263
                    [% END %]
264
265
                    [%# Success for new versions %]
247
                    [% IF success %]
266
                    [% IF success %]
248
                        <p>Update report:</p>
249
                        <ul>
267
                        <ul>
250
                            [% FOR s IN success %]
268
                            [% FOR s IN success %]
251
                                [% FOR o IN s.output %]
269
                                [% FOR o IN s.output %]
Lines 257-262 Link Here
257
                            [% END %]
275
                            [% END %]
258
                        </ul>
276
                        </ul>
259
                    [% END %]
277
                    [% END %]
278
279
                    [%# Errors for old versions %]
280
                    [% IF has_update_errors %]
281
                        <p>Update errors :</p>
282
                        <ul>
283
                            [% FOREACH update_error IN update_errors %]
284
                                <li class="update_error">[% update_error.line | html %]</li>
285
                            [% END %]
286
                        </ul>
287
                    [% END %]
288
289
                    [%# Errors for new versions %]
260
                    [% IF error %]
290
                    [% IF error %]
261
                        <p>Update error :</p>
291
                        <p>Update error :</p>
262
                        <ul>
292
                        <ul>
Lines 275-281 Link Here
275
                            [% END %]
305
                            [% END %]
276
                        </ul>
306
                        </ul>
277
                    [% END %]
307
                    [% END %]
278
                    [% UNLESS error %]
308
                    [% UNLESS error OR has_update_errors %]
279
                        <p>Everything went okay. Update done.</p>
309
                        <p>Everything went okay. Update done.</p>
280
                        <p><a href="install.pl?step=3&amp;op=finished" class="btn btn-primary">Continue to log in to Koha</a></p>
310
                        <p><a href="install.pl?step=3&amp;op=finished" class="btn btn-primary">Continue to log in to Koha</a></p>
281
                    [% ELSE %]
311
                    [% ELSE %]
282
- 

Return to bug 25078