Koha/about.pl
Jonathan Druart c9cb55ef47 Bug 7167: New version for updatedatabase
This patch use DataTable, see BUG|BZ 6836
      - css/datatables.css
      - lib/jquery/plugins/jquery.dataTables.min.js
      - js/datatables.js

http://bugs.koha-community.org/show_bug.cgi?id=7167

Bug 7167 follow-up

Major changes:
* creating database tables for update on the fly, the  1st time the update script is called
* version is checked on mainpage.pl (and here only). If syspref Version differ from kohaversion.pl, the old updatedatabase is launched. If there are updates missing from new mechanism, the updatedatabase page is reached
* kohaversion check on each page is now useless in Auth.pm, removed dead code
* Updated installer: at the end of the process, retrieve all updates and automatically mark them "OK", as they're included in installer

Minor changes:
* adding copyright
* adding poddoc
* updating a warning, for better clarity
* switching from $$var to $var->
* small TT glitch fixed in updatedatabase.tt
* about.pl now returns the Version systempreference PLUS all the patches that have been applied

Bug 7167 follow-up perlcritic & numbers display & partial apply depending on DEBUG

* add use strict to updatedatabase, that is now perlcritic compliant
* partial apply of DB revs is now managed by DEBUG env variable = if DEBUG=0, the user can just apply every DBrev. If DEBUG=1, we're in a dev env, the user know has the option to apply DBrevs one by one
Display:
* in updatedatabase, small spelling changes
* in about.pl, remove 0 just after . (3.06.01 is displayed as 3.6.1)
* improve the display of applied numbers on about.pl
 - before this patch, if you have N, N+1, N+2, N+3 and N+10 DB rev applied, about was displaying : , N+1 / N+2 / N+3 / N+10
 - after this patch you have N......N+3 / N+10
* add ORDER BY into list_versions_already_knows to have number retrieved in the same order whatever the order they are applied

http://bugs.koha-community.org/show_bug.cgi?id=6679
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: Improve the update.pl script

 * Added CLI options to update.pl
 * Call update.pl from the installer.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: Now, we check versions on mainpage.pl and after login

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: Reimplementing Marcel's suggestions & fixes

 * Fixing the bugguy old version check (that was made against 3.0900000 instead of 3.0900027 -the last current kohaversion number
 * in the CLI script, if there is nothing to report, just say it

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>

Bug 7167: Remove check_coherency

As suggested by Katrin, we've removed the call to check_coherency. It intended to provide readable comments when some SQL was wrong. Removing this sub result in the SQL error being displayed. That's OK because the sysadmin or the developer can google the error, understand it, then fix it.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: Changing in .sql parsing

We first split on delimiter and then extract comments. You can now put
\n for delimiter comments.
ex:

DELIMITER ;
-- this is a comment
SELECT * FROM  my_table;
-- another comment

Before this patch, we had to write:
DELIMITER ;
-- this is a comment;
SELECT * FROM  my_table;
-- another comment;

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: Add .pl and .sql examples

Those files are in version directory, so will never be executed by the updater
If you want to provide an update, do it in a 3.09/ directory (if your update is expected for 3.10 version)

Note that the updater use a md5sum checker. So, if the same update is in 2 different places, it will be detected. That will be handy for changes made on both stable and master: a library running stable will get the update when updating. When upgrading to the next major release, Koha will detect the patch has already been applied, and no error will be thrown. With the previous mechanism, a DBRev ported to stable was re-executed when upgrading to master, resulting in a nasty (but usually harmless) error message

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: Improve display + factorize get_queries

Despite it's size, this patch is dealing with display questions only:
 * The text "comments" and "queries" was hardcoded in ajax-updatedb-getinfo.pl script. It has been replaced by a JSON call, returning 2 separate values, "comments:" and "queries:" is now in the template, making it translatable
 * Some minor tweak in the display (like putting things in bold, displaying OK in green, warnings in yellow and KO in red)
 * Reordering the column headers for more readability:
    * Status column is merged with availability, column is after status
    * Status/availability terms more clear: "Not applied" instead of "unknown", "Applied and OK", "Applied and failed", "Applied and forced" are the 3 other statuses
    * Removed one click to display comments on DBREv not yet applied: before the patch, one had to click "Show details", then "Get comments", now, "Get comments" is enough

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: FIX typos & moving a script to a proper place

* renamed availables to available
* renamed already_knows to already_applied
* fixed FSF & copyright headers
* removing a "use strict" because we already had use Modern::Perl
* fixed a tiny typo in about.tt

* moving update.pl to misc/bin because it's a CLI script

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: Add dependency File::Find::Rule

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: We want to execute non-numeric version with the -all option

Dealing with Marcel comment 100:
> Note that the current code around line 52/53 does not
> handle that correctly:
> Argument "\x{74}\x{65}..." isn't numeric in numeric ge (>=) at
> installer/data/mysql/update.pl line 52.

Now, a non-numeric DBRev will be applied if you provide the --all parameter, without throwing the error

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167 reindentation & removing dead code

* The if (! defined $ENV{PERL5LIB}... block was wrongly intented
* The 3 lines running update.pl are useless: the update (new mechanism) is run from admin/updatedatabase.pl script. This part of install.pl is run only when you have "old style" DB revisions.

Summary:
 * old mechanism = it's run as previously, by reaching the installer/install.pl?step=3 page, that applies all revisions
 * new mechanism = when you log-in or reach mainpage.pl, you reach admin/updatedatabase.pl, where you can see what will be run, and run it

Tiny side effect = the check for old mechanism is now done *after* authentification (thus it's not done on each page call). It means that the user will have to enter login/password twice :
 * first to log-in to Koha
 * second to run installer/updatedatabase.pl?step=3
As the old mechanism is deprecated, we can expect this will happend only a few time in the history of a setup, it's not a big deal.

Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: Don't raise an error in routine TableExists

Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: FIX merge

Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167: Add .pl and .sql examples

Those files are in version directory, so will never be executed by the updater
If you want to provide an update, do it in a 3.09/ directory (if your update is expected for 3.10 version)

Note that the updater use a md5sum checker. So, if the same update is in 2 different places, it will be detected. That will be handy for changes made on both stable and master: a library running stable will get the update when updating. When upgrading to the next major release, Koha will detect the patch has already been applied, and no error will be thrown. With the previous mechanism, a DBRev ported to stable was re-executed when upgrading to master, resulting in a nasty (but usually harmless) error message

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu>

Bug 7167 follow-up fix POD syntax to please koha-qa.pl
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
2012-12-27 11:13:54 -05:00

224 lines
6.9 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright Pat Eyler 2003
# Copyright Biblibre 2006
# Parts Copyright Liblime 2008
# Parts Copyright Chris Nighswonger 2010
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
use CGI;
use LWP::Simple;
use XML::Simple;
use Config;
use C4::Output;
use C4::Auth;
use C4::Context;
use C4::Installer;
use C4::Update::Database;
#use Smart::Comments '####';
my $query = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "about.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { catalogue => 1 },
debug => 1,
}
);
my $kohaVersion = C4::Context->preference("Version");
# restore ., for display consistency
$kohaVersion =~ /(.)\.(..)(..)(...)/;
# transform digits to Perl number, to display 3.6.1.2 instead of 3.06.01.002
$kohaVersion = ($1+0).".".($2+0).".".($3+0).".".($4+0);
my $dbrev_applied=""; # the list of database revisions
# the $kohaVersion is duplicated since 3.7: the 3.6 (that uses the old mechanism) and the 3.7 (new mechanism).
# Both versions reflects how the database has been upgraded
my $already_applied = C4::Update::Database::list_versions_already_applied();
# $last_known contains the previous DBrev applied number (all . removed). It's used to have a . instead of a number in case of continuous updates
my $last_known=0;
# $last_known_sep contains the previous DBrev applied with the separator (used for display)
my $last_known_sep="";
for my $v ( @$already_applied ) {
my $current = $v->{version};
$current =~s/\.//g;
# if the current number is the previous one +1, then just add a ., for a better display N.........N+10, for example
# (instead of N / N+1 / N+2 / ...)
if ($current==$last_known+1) {
$dbrev_applied.=".";
} else { # we're not N+1, start a new range
# if version don't end by a ., no need to add the current loop number
# this avoid having N...N (in case of an isolated BDrev number)
if ($last_known & $dbrev_applied =~ /\.$/) {
$dbrev_applied .= "...".$last_known_sep;
}
# start a new range
$dbrev_applied .= " ".$v->{version};
}
$last_known= $current;
$last_known_sep=$v->{version};
}
# add the last DB rev number, we don't want to end with "..."
if ($dbrev_applied =~ /\.$/) {
$dbrev_applied .= "...".$last_known_sep;
}
my $osVersion = `uname -a`;
my $perl_path = $^X;
if ($^O ne 'VMS') {
$perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
}
my $perlVersion = $];
my $mysqlVersion = `mysql -V`;
my $apacheVersion = `httpd -v 2> /dev/null`;
$apacheVersion = `httpd2 -v 2> /dev/null` unless $apacheVersion;
$apacheVersion = (`/usr/sbin/apache2 -V`)[0] unless $apacheVersion;
my $zebraVersion = `zebraidx -V`;
# Additional system information for warnings
my $prefNoZebra = C4::Context->preference('nozebra');
my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBiblioAddsAuthorities) );
my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords');
my $prefUseControlNumber = C4::Context->preference('UseControlNumber');
my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber );
my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
my $warnIsRootUser = (! $loggedinuser);
$template->param(
kohaVersion => $kohaVersion,
dbrev_applied => $dbrev_applied,
osVersion => $osVersion,
perlPath => $perl_path,
perlVersion => $perlVersion,
perlIncPath => [ map { perlinc => $_ }, @INC ],
mysqlVersion => $mysqlVersion,
apacheVersion => $apacheVersion,
zebraVersion => $zebraVersion,
prefNoZebra => $prefNoZebra,
prefBiblioAddsAuthorities => $prefBiblioAddsAuthorities,
prefAutoCreateAuthorities => $prefAutoCreateAuthorities,
warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities,
warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords,
errZebraConnection => $errZebraConnection,
warnIsRootUser => $warnIsRootUser,
);
my @components = ();
my $perl_modules = C4::Installer::PerlModules->new;
$perl_modules->version_info;
my @pm_types = qw(missing_pm upgrade_pm current_pm);
foreach my $pm_type(@pm_types) {
my $modules = $perl_modules->get_attr($pm_type);
foreach (@$modules) {
my ($module, $stats) = each %$_;
push(
@components,
{
name => $module,
version => $stats->{'cur_ver'},
missing => ($pm_type eq 'missing_pm' ? 1 : 0),
upgrade => ($pm_type eq 'upgrade_pm' ? 1 : 0),
current => ($pm_type eq 'current_pm' ? 1 : 0),
require => $stats->{'required'},
}
);
}
}
@components = sort {$a->{'name'} cmp $b->{'name'}} @components;
my $counter=0;
my $row = [];
my $table = [];
foreach (@components) {
push (@$row, $_);
unless (++$counter % 4) {
push (@$table, {row => $row});
$row = [];
}
}
# Processing the last line (if there are any modules left)
if (scalar(@$row) > 0) {
# Extending $row to the table size
$$row[3] = '';
# Pushing the last line
push (@$table, {row => $row});
}
## ## $table
$template->param( table => $table );
## ------------------------------------------
## Koha time line code
#get file location
my $dir = C4::Context->config('intranetdir');
open( my $file, "<", "$dir" . "/docs/history.txt" );
my $i = 0;
my @rows2 = ();
my $row2 = [];
my @lines = <$file>;
close($file);
shift @lines; #remove header row
foreach (@lines) {
my ( $date, $desc, $tag ) = split(/\t/);
if(!$desc && $date=~ /(?<=\d{4})\s+/) {
($date, $desc)= ($`, $');
}
push(
@rows2,
{
date => $date,
desc => $desc,
}
);
}
my $table2 = [];
#foreach my $row2 (@rows2) {
foreach (@rows2) {
push (@$row2, $_);
push( @$table2, { row2 => $row2 } );
$row2 = [];
}
$template->param( table2 => $table2 );
output_html_with_http_headers $query, $cookie, $template->output;