[Patches] [PATCH] Bug 7167 follow-up perlcritic & numbers display & partial
koha-patchbot at kohaaloha.com
koha-patchbot at kohaaloha.com
Tue Dec 13 22:05:43 NZDT 2011
From: Paul Poulain <paul.poulain at biblibre.com>
Date: Mon, 12 Dec 2011 15:18:10 +0100
Subject: [PATCH] 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
---
C4/Update/Database.pm | 6 ++--
about.pl | 31 ++++++++++++++++++++
admin/updatedatabase.pl | 2 +
.../prog/en/modules/admin/updatedatabase.tt | 12 ++++---
4 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/C4/Update/Database.pm b/C4/Update/Database.pm
index 95abbff..caed693 100644
--- a/C4/Update/Database.pm
+++ b/C4/Update/Database.pm
@@ -202,7 +202,7 @@ sub list_versions_already_knows {
CREATE TABLE IF NOT EXISTS `updatedb_report` ( `version` text, `md5` varchar(50) DEFAULT NULL, `comment` text, `status` int(1) DEFAULT NULL ) ENGINE=InnoDB CHARSET=utf8;
});
- my $query = qq/ SELECT version, comment, status FROM updatedb_report /;
+ my $query = qq/ SELECT version, comment, status FROM updatedb_report ORDER BY version/;
my $sth = $dbh->prepare( $query );
$sth->execute;
my $versions = $sth->fetchall_arrayref( {} );
@@ -214,12 +214,12 @@ sub list_versions_already_knows {
} @$versions;
$sth->finish;
for my $version ( @$versions ) {
- $query = qq/ SELECT query FROM updatedb_query WHERE version = ? /;
+ $query = qq/ SELECT query FROM updatedb_query WHERE version = ? ORDER BY version/;
$sth = $dbh->prepare( $query );
$sth->execute( $version->{version} );
$version->{queries} = $sth->fetchall_arrayref( {} );
$sth->finish;
- $query = qq/ SELECT error FROM updatedb_error WHERE version = ? /;
+ $query = qq/ SELECT error FROM updatedb_error WHERE version = ? ORDER BY version/;
$sth = $dbh->prepare( $query );
$sth->execute( $version->{version} );
$version->{errors} = $sth->fetchall_arrayref( {} );
diff --git a/about.pl b/about.pl
index 859d6ec..7d232c5 100755
--- a/about.pl
+++ b/about.pl
@@ -47,12 +47,43 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
);
my $kohaVersion = C4::Context->preference("Version");
+# restore ., for display consistency
+$kohaVersion =~ /(.)\.(..)(..)(...)/;
+$kohaVersion = "$1.$2.$3.$4";
# 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_knows = C4::Update::Database::list_versions_already_knows();
+# $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_knows ) {
+ 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) {
+ $kohaVersion.=".";
+ } 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 & $kohaVersion =~ /\.$/) {
+ $kohaVersion .= "...".$last_known_sep;
+ }
+ # start a new range
$kohaVersion .= " / ".$v->{version};
+ }
+ $last_known= $current;
+ $last_known_sep=$v->{version};
+}
+# add the last DB rev number, we don't want to end with "..."
+if ($kohaVersion =~ /\.$/) {
+ $kohaVersion .= "...".$last_known_sep;
}
+
+# remove any 0 just after a . for better readability (3.06.02.001 will become 3.6.2.1)
+$kohaVersion =~ s/\.0+/\./g;
+
my $osVersion = `uname -a`;
my $perl_path = $^X;
if ($^O ne 'VMS') {
diff --git a/admin/updatedatabase.pl b/admin/updatedatabase.pl
index 854c759..d43c3b3 100755
--- a/admin/updatedatabase.pl
+++ b/admin/updatedatabase.pl
@@ -16,6 +16,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
+use strict;
use CGI;
use C4::Auth;
use C4::Output;
@@ -92,6 +93,7 @@ if ( $op eq 'list' ) {
my @v_availables = map { {version => $$_{version}} } @availables;
$template->param(
+ dev_mode => $ENV{DEBUG},
versions => \@sorted,
nb_availables => scalar @availables,
availables => [ map { {version => $$_{version}} } @availables ],
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/updatedatabase.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/updatedatabase.tt
index c624664..c94d67f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/updatedatabase.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/updatedatabase.tt
@@ -37,7 +37,7 @@
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › Update Database</div>
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › Database update</div>
<div id="doc3" class="yui-t2">
@@ -45,7 +45,7 @@
<div id="yui-main">
<div class="yui-b">
- <h2>Update Database</h2>
+ <h2>Database update</h2>
[% IF report_loop %]
<div class="report" style="display:block; margin:1em;">
Report :
@@ -66,7 +66,7 @@
[% END %]
<span class="infos" style="display:block; margin:1em;">
[% IF nb_availables %]
- [% nb_availables %] versions are availables [ <a href="/cgi-bin/koha/admin/updatedatabase.pl?op=update[% FOREACH av IN availables %]&version=[% av.version %][% END %]">UPDATE</a> ]
+ [% nb_availables %] update(s) available [ <a href="/cgi-bin/koha/admin/updatedatabase.pl?op=update[% FOREACH av IN availables %]&version=[% av.version %][% END %]">UPDATE</a> ]
[% ELSE %]
Your database is up to date
[% END %]
@@ -75,10 +75,10 @@
<table id="versionst">
<thead>
<tr>
- <th>Version</th>
+ <th>DB revision</th>
<th>Comments</th>
<th>Status</th>
- <th>Launch</th>
+ <th>Availability</th>
<th>Details</th>
</tr>
</thead>
@@ -110,7 +110,9 @@
<td>
[% IF v.available %]
Available
+ [% IF (dev_mode) %]
[<a href="/cgi-bin/koha/admin/updatedatabase.pl?op=update&version=[% v.version %]">Execute</a>]
+ [% END %]
[% ELSE %]
Already executed
[% END %]
--
1.7.5.4
More information about the Patches
mailing list