From 8767b123c4be2301ad96e700fbe708045361decf Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 3 Jul 2007 13:50:20 +0000 Subject: [PATCH] improving installer : now the database Version is compared to the Koha version (defined by XXX in koha.xml file. If the Version systempref does not exist or is lower than kohaversion, you're redirected to installer. If there is no Version, you're redirected to the 1st step of the installer (full install). If Version < kohaversion, you're redirected to step 3 (updatedatabase). check that you have in you koha.xml, otherwise, you'l loop forever to the installer... --- C4/Auth.pm | 8 +++++++- installer/install.pl | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 2be8ba98ee..428c526940 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -338,11 +338,17 @@ sub checkauth { $type = 'opac' unless $type; my $dbh = C4::Context->dbh; + # check that database and koha version are the same unless (C4::Context->preference('Version')){ - warn "No Version string in sysprefs, redirecting to Installer"; + warn "Install required, redirecting to Installer"; print $query->redirect("/cgi-bin/koha/installer/install.pl"); exit; } + if (C4::Context->preference('Version') < C4::Context->config("kohaversion")){ + warn "Database update needed, redirecting to Installer. Database is ".C4::Context->preference('Version')." and Koha is : ".C4::Context->config("kohaversion"); + print $query->redirect("/cgi-bin/koha/installer/install.pl?step=3"); + exit; + } my $timeout = C4::Context->preference('timeout'); $timeout = 600 unless $timeout; diff --git a/installer/install.pl b/installer/install.pl index 5f9c18215e..47ba99694b 100755 --- a/installer/install.pl +++ b/installer/install.pl @@ -203,6 +203,15 @@ if ($step && $step==1){ } elsif ($step && $step==3){ my $op=$query->param('op'); if ($op && $op eq 'finish'){ + if (C4::Context->preference('Version')) { + warn "UPDATE Version"; + my $finish=$dbh->prepare("UPDATE systempreferences SET value=? WHERE variable='Version'"); + $finish->execute(C4::Context->config("kohaversion")); + } else { + warn "INSERT Version"; + my $finish=$dbh->prepare("INSERT into systempreferences (variable,value,explanation) values ('Version',?,'The Koha database version. Don t change this value manually, it s holded by the webinstaller')"); + $finish->execute(C4::Context->config("kohaversion")); + } # Installation is finished. # We just deny anybody acess to install # And we redirect people to mainpage. -- 2.39.5