Bug 14152: Re-check required dependencies during upgrade process
authorChris Nighswonger <chris.nighswonger@gmail.com>
Tue, 5 May 2015 19:00:30 +0000 (15:00 -0400)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 18 May 2015 15:12:33 +0000 (12:12 -0300)
This code causes the installer to re-check dependencies during the
upgrade process.

Test Plan
---------
1) Log in to staff client
2) Koha Administration -> Global system preferences -> Local
3) Change Version to previous version -- DO NOT HIT SAVE YET!
4) In command line: sudo apt-get purge libpdf-fromhtml-perl
   NOTE: This could be ANY required library. I chose
         PDF::FromHTML, because it has been a thorn in my side.
5) NOW! Hit the 'Save' button.
6) Log in, etc. etc...
   -- Blows up on redirect to log in.
7) In command line, add it back (I had to compile my own so,
   I used sudo dpkg -i /path/to/libpdf-fromhtml-perl...)
8) Apply patch
9) Edit the C4/Installer/PerlDependencies.pm to make
   PDF::FromHTML required. See also bug 14103.
10) Log in to staff client
11) Koha Administration -> Global system preferences -> Local
12) Change Version to previous version -- DO NOT HIT SAVE YET!
13) In command line: sudo apt-get purge libpdf-fromhtml-perl
14) NOW! Hit the 'Save' button.
15) Log in, etc. etc...
16) Once warned you are missing it, add it back at the command line.
17) Click 'Recheck'
    -- Proceeds as expected now.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
C4/Auth.pm
installer/install.pl
koha-tmpl/intranet-tmpl/prog/en/modules/installer/step1.tt

index 9a5d6b4..e136753 100644 (file)
@@ -672,7 +672,7 @@ sub _version_check {
         my $warning = "Database update needed, redirecting to %s. Database is $version and Koha is $kohaversion";
         if ( $type ne 'opac' ) {
             warn sprintf( $warning, 'Installer' );
-            print $query->redirect("/cgi-bin/koha/installer/install.pl?step=3");
+            print $query->redirect("/cgi-bin/koha/installer/install.pl?step=1&op=updatestructure");
         } else {
             warn sprintf( "OPAC: " . $warning, 'maintenance' );
             print $query->redirect("/cgi-bin/koha/maintenance.pl");
index 6b56777..056107e 100755 (executable)
@@ -55,9 +55,10 @@ my $dbh = DBI->connect(
 );
 
 if ( $step && $step == 1 ) {
-    #First Step
+    #First Step (for both fresh installations and upgrades)
     #Checking ALL perl Modules and services needed are installed.
     #Whenever there is an error, adding a report to the page
+    my $op = $query->param('op') || 'noop';
     $template->param( language => 1 );
     $template->param( 'checkmodule' => 1 ); # we start with the assumption that there are no problems and set this to 0 if there are
 
@@ -86,7 +87,7 @@ if ( $step && $step == 1 ) {
             );
         }
         @components = sort {$a->{'name'} cmp $b->{'name'}} @components;
-        $template->param( missing_modules => \@components, checkmodule => $checkmodule );
+        $template->param( missing_modules => \@components, checkmodule => $checkmodule, op => $op );
     }
 }
 elsif ( $step && $step == 2 ) {
@@ -314,13 +315,13 @@ elsif ( $step && $step == 3 ) {
         #
         #Do updatedatabase And report
 
-    if ( ! defined $ENV{PERL5LIB} ) {
-        my $find = "C4/Context.pm";
-        my $path = $INC{$find};
-        $path =~ s/\Q$find\E//;
-        $ENV{PERL5LIB} = "$path:$path/installer";
-        warn "# plack? inserted PERL5LIB $ENV{PERL5LIB}\n";
-    }
+        if ( ! defined $ENV{PERL5LIB} ) {
+            my $find = "C4/Context.pm";
+            my $path = $INC{$find};
+            $path =~ s/\Q$find\E//;
+            $ENV{PERL5LIB} = "$path:$path/installer";
+            warn "# plack? inserted PERL5LIB $ENV{PERL5LIB}\n";
+        }
 
         my $now = POSIX::strftime( "%Y-%m-%dT%H:%M:%S", localtime() );
         my $logdir = C4::Context->config('logdir');
index 038c9dc..4fb70b5 100644 (file)
@@ -30,7 +30,9 @@ listed, please inform your systems administrator.</p>
 </form>
 [% END %]
 [% IF ( language ) %]
-  [% UNLESS ( checkmodule ) %]
+  [% IF ( checkmodule ) %]
+  <p>All required Perl modules appear to be installed.<br />
+  [% ELSE %]
   [% IF ( missing_modules ) %]
   <p>Some Perl modules are missing. Modules in red <b>must</b> be installed before you may continue.<br />
   <ul>
@@ -57,11 +59,22 @@ listed, please inform your systems administrator.</p>
   [% END %]
 <form name="checkmodules" action="install.pl">
 [% IF ( checkmodule ) %]
+[% IF (op == 'noop') %]
 <input type="hidden" name="step" value="2" />
+[% ELSE %]
+<input type="hidden" name="step" value="3" />
+<input type="hidden" name="op" value="[% op %]" />
+<input type="hidden" name="checkmodule" value="[% checkmodule %]"/>
+[% END %]
 <p> All dependencies installed.</p>
 <p>Please click 'Next' to continue <input value="Next &gt;&gt;" type="submit" /></p>
 [% ELSE %]
+[% IF (op == 'noop') %]
 <input type="hidden" name="step" value="1" />
+[% ELSE %]
+<input type="hidden" name="step" value="1" />
+<input type="hidden" name="op" value="[% op %]" />
+[% END %]
 <p>Click to recheck dependencies <input value="Recheck" type="submit" /></p>
 [% END %]
 </form>