Bugzilla – Attachment 13429 Details for
Bug 7167
updatedatabase improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7167: Remove check_coherency
Bug-7167-Remove-checkcoherency.patch (text/plain), 8.60 KB, created by
Chris Nighswonger
on 2012-11-13 15:58:56 UTC
(
hide
)
Description:
Bug 7167: Remove check_coherency
Filename:
MIME Type:
Creator:
Chris Nighswonger
Created:
2012-11-13 15:58:56 UTC
Size:
8.60 KB
patch
obsolete
>From 59d41733ee4519d7f34986ecae78a3f4bef00543 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 31 Jul 2012 10:49:35 +0200 >Subject: [PATCH] Bug 7167: Remove check_coherency >Content-Type: text/plain; charset="utf-8" > >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> >--- > C4/Update/Database.pm | 150 ++++++++------------ > admin/updatedatabase.pl | 3 - > .../prog/en/modules/admin/updatedatabase.tt | 3 - > 3 files changed, 61 insertions(+), 95 deletions(-) > >diff --git a/C4/Update/Database.pm b/C4/Update/Database.pm >index f43bd44..8ab5840 100644 >--- a/C4/Update/Database.pm >+++ b/C4/Update/Database.pm >@@ -152,23 +152,7 @@ sub execute_version { > return $report > if ( defined $report->{$version} ); > >- my $errors; >- for my $query ( @{$queries->{queries}} ) { >- eval { >- check_coherency( $query ); >- }; >- if ( $@ ) { >- push @$errors, $@ >- } >- } >- >- if ( $errors ) { >- $_ =~ s/at [^ ]* line \d*\.$// for @$errors; >- $report->{$version} = $errors; >- return $report; >- } >- >- $errors = execute ( $queries ); >+ my $errors = execute ( $queries ); > $report->{$version} = scalar( @$errors ) ? $errors : "OK"; > set_infos ( $version, $queries, $errors, $md5 ); > return $report; >@@ -280,7 +264,7 @@ my $tables; > > =head2 check_coherency > >- my $errors = check_coherency($query); >+ my $errors = check_coherency($query); UNUSED > This sub will try to check if a SQL query is useless or no. > for queries that are CREATE TABLE, it will check if the table already exists > for queries that are ALTER TABLE, it will search if the modification has already been made >@@ -290,62 +274,62 @@ my $tables; > > =cut > >-sub check_coherency { >- my ( $query ) = @_; >- $tables = get_tables_name() if not $tables; >- >- given ( $query ) { >- when ( /CREATE TABLE(?:.*?)? `?(\w+)`?/ ) { >- my $table_name = $1; >- if ( grep { /$table_name/ } @$tables ) { >- die "COHERENCY: Table $table_name already exists"; >- } >- } >- >- when ( /ALTER TABLE *`?(\w+)`? *ADD *(?:COLUMN)? `?(\w+)`?/ ) { >- my $table_name = $1; >- my $column_name = $2; >- next if $column_name =~ /(UNIQUE|CONSTRAINT|INDEX|KEY|FOREIGN)/; >- if ( not grep { /$table_name/ } @$tables ) { >- return "COHERENCY: Table $table_name does not exist"; >- } else { >- my $sth = $dbh->prepare( "DESC $table_name $column_name" ); >- my $rv = $sth->execute; >- if ( $rv > 0 ) { >- die "COHERENCY: Field $table_name.$column_name already exists"; >- } >- } >- } >- >- when ( /INSERT INTO `?(\w+)`?.*?VALUES *\((.*?)\)/ ) { >- my $table_name = $1; >- my @values = split /,/, $2; >- s/^ *'// foreach @values; >- s/' *$// foreach @values; >- given ( $table_name ) { >- when ( /systempreferences/ ) { >- my $syspref = $values[0]; >- my $sth = $dbh->prepare( "SELECT COUNT(*) FROM systempreferences WHERE variable = ?" ); >- $sth->execute( $syspref ); >- if ( ( my $count = $sth->fetchrow_array ) > 0 ) { >- die "COHERENCY: Syspref $syspref already exists"; >- } >- } >- >- when ( /permissions/){ >- my $module_bit = $values[0]; >- my $code = $values[1]; >- my $sth = $dbh->prepare( "SELECT COUNT(*) FROM permissions WHERE module_bit = ? AND code = ?" ); >- $sth->execute($module_bit, $code); >- if ( ( my $count = $sth->fetchrow_array ) > 0 ) { >- die "COHERENCY: Permission $code already exists"; >- } >- } >- } >- } >- } >- return 1; >-} >+#sub check_coherency { >+# my ( $query ) = @_; >+# $tables = get_tables_name() if not $tables; >+# >+# given ( $query ) { >+# when ( /CREATE TABLE(?:.*?)? `?(\w+)`?/ ) { >+# my $table_name = $1; >+# if ( grep { /$table_name/ } @$tables ) { >+# die "COHERENCY: Table $table_name already exists"; >+# } >+# } >+# >+# when ( /ALTER TABLE *`?(\w+)`? *ADD *(?:COLUMN)? `?(\w+)`?/ ) { >+# my $table_name = $1; >+# my $column_name = $2; >+# next if $column_name =~ /(UNIQUE|CONSTRAINT|INDEX|KEY|FOREIGN)/; >+# if ( not grep { /$table_name/ } @$tables ) { >+# return "COHERENCY: Table $table_name does not exist"; >+# } else { >+# my $sth = $dbh->prepare( "DESC $table_name $column_name" ); >+# my $rv = $sth->execute; >+# if ( $rv > 0 ) { >+# die "COHERENCY: Field $table_name.$column_name already exists"; >+# } >+# } >+# } >+# >+# when ( /INSERT INTO `?(\w+)`?.*?VALUES *\((.*?)\)/ ) { >+# my $table_name = $1; >+# my @values = split /,/, $2; >+# s/^ *'// foreach @values; >+# s/' *$// foreach @values; >+# given ( $table_name ) { >+# when ( /systempreferences/ ) { >+# my $syspref = $values[0]; >+# my $sth = $dbh->prepare( "SELECT COUNT(*) FROM systempreferences WHERE variable = ?" ); >+# $sth->execute( $syspref ); >+# if ( ( my $count = $sth->fetchrow_array ) > 0 ) { >+# die "COHERENCY: Syspref $syspref already exists"; >+# } >+# } >+# >+# when ( /permissions/){ >+# my $module_bit = $values[0]; >+# my $code = $values[1]; >+# my $sth = $dbh->prepare( "SELECT COUNT(*) FROM permissions WHERE module_bit = ? AND code = ?" ); >+# $sth->execute($module_bit, $code); >+# if ( ( my $count = $sth->fetchrow_array ) > 0 ) { >+# die "COHERENCY: Permission $code already exists"; >+# } >+# } >+# } >+# } >+# } >+# return 1; >+#} > > =head2 get_error > >@@ -462,22 +446,10 @@ sub mark_as_ok { > my $sth = $dbh->prepare( "UPDATE updatedb_report SET status = 2 WHERE version=?" ); > my $affected = $sth->execute( $version ); > if ( $affected < 1 ) { >- # For "Coherency" > my $filepath = get_filepath $version; >- my $queries = get_queries $filepath; >- my $errors; >- for my $query ( @{$queries->{queries}} ) { >- eval { >- check_coherency( $query ); >- }; >- if ( $@ ) { >- push @$errors, $@ >- } >- } >- >- $_ =~ s/at [^ ]* line \d*\.$// for @$errors; >- my $md5 = get_md5 $filepath; >- set_infos $version, $queries, $errors, $md5; >+ my $queries = get_queries $filepath; >+ my $md5 = get_md5 $filepath; >+ set_infos $version, $queries, undef, $md5; > > $sth->execute( $version ); > } >diff --git a/admin/updatedatabase.pl b/admin/updatedatabase.pl >index 5735451..3b660ac 100755 >--- a/admin/updatedatabase.pl >+++ b/admin/updatedatabase.pl >@@ -57,9 +57,6 @@ if ( $op eq 'update' ) { > { > version => $v, > report => \@errors, >- coherency => ( ref ( $r ) eq 'ARRAY' >- ? @$r[0] =~ /COHERENCY/ ? 1 : 0 >- : $r =~ /COHERENCY/ ? 1 : 0 ) > } > } @reports; > $template->param( report_loop => \@report_loop ); >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 5962fdf..706dbf7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/updatedatabase.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/updatedatabase.tt >@@ -67,9 +67,6 @@ > [% r.error %]; > [% END %] > [% END %] >- [% IF report_loo.coherency %] >- [<a href="/cgi-bin/koha/admin/updatedatabase.pl?op=mark_as_ok&version=[% report_loo.version %]">Mark as OK</a>] >- [% END %] > </li> > [% END %] > </ul> >-- >1.7.9.5
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