Bugzilla – Attachment 6722 Details for
Bug 7167
updatedatabase improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7167 follow-up 2 perlcritic & numbers display & partial apply depending on DEBUG
Bug-7167-follow-up-perlcritic--numbers-display--pa.patch (text/plain), 7.65 KB, created by
Paul Poulain
on 2011-12-12 14:18:33 UTC
(
hide
)
Description:
Bug 7167 follow-up 2 perlcritic & numbers display & partial apply depending on DEBUG
Filename:
MIME Type:
Creator:
Paul Poulain
Created:
2011-12-12 14:18:33 UTC
Size:
7.65 KB
patch
obsolete
>From 2eb2c1fe507194602418ba7a6ad825e65054d529 Mon Sep 17 00:00:00 2001 >From: Paul Poulain <paul.poulain@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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7167
:
6377
|
6378
|
6379
|
6381
|
6414
|
6415
|
6416
|
6476
|
6477
|
6478
|
6479
|
6722
|
6832
|
7903
|
8178
|
9859
|
9860
|
9861
|
9862
|
10033
|
10034
|
10549
|
10666
|
10667
|
10668
|
10825
|
11129
|
11222
|
11223
|
11224
|
11225
|
11226
|
11227
|
11228
|
11229
|
11230
|
11231
|
11232
|
11235
|
11236
|
11237
|
11238
|
11239
|
11240
|
11241
|
11242
|
11243
|
11244
|
11245
|
11246
|
11571
|
13423
|
13424
|
13425
|
13426
|
13427
|
13428
|
13429
|
13430
|
13431
|
13432
|
13433
|
13434
|
13435
|
13436
|
13437
|
13456
|
13457
|
13509
|
13516
|
13517
|
13518
|
13519
|
13520
|
13521
|
13522
|
13523
|
13524
|
13525
|
13526
|
13527
|
13528
|
13529
|
13733
|
13734
|
13842
|
13845
|
13848
|
13851
|
13852
|
13853
|
13854
|
14310
|
16113
|
16114
|
16115
|
16116
|
16117
|
16596