Bugzilla – Attachment 116208 Details for
Bug 25078
Update DB process - wrap each DBRev inside a transaction and better error handling
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25078: [POC] Lazy version
Bug-25078-POC-Lazy-version.patch (text/plain), 3.68 KB, created by
Jonathan Druart
on 2021-02-02 12:05:51 UTC
(
hide
)
Description:
Bug 25078: [POC] Lazy version
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-02-02 12:05:51 UTC
Size:
3.68 KB
patch
obsolete
>From e11f4561162c0b0bc15672dbf9ed3b880db8da27 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 29 Jan 2021 12:50:27 +0100 >Subject: [PATCH] Bug 25078: [POC] Lazy version > >This is the lazy, quick and dirty, version. >We use a try catch block and execute the db entry in a transaction. >When I error is found, we stop. > >The main problem is that we cannot do anything with the raw output in >the template. > >execute_entry + try + txn_do > >Why do /var/log/koha/kohadev/updatedatabase_*.log (not -error) contain > Status: 500 > Content-type: text/html > > <h1>Software error:</h1> >etc. > >??? >--- > Koha.pm | 2 +- > installer/data/mysql/updatedatabase.pl | 36 +++++++++++++++++-- > .../prog/en/modules/installer/step3.tt | 2 +- > 3 files changed, 36 insertions(+), 4 deletions(-) > >diff --git a/Koha.pm b/Koha.pm >index 3f97959709..d2206842d6 100644 >--- a/Koha.pm >+++ b/Koha.pm >@@ -29,7 +29,7 @@ use vars qw{ $VERSION }; > # - #4 : the developer version. The 4th number is the database subversion. > # used by developers when the database changes. updatedatabase take care of the changes itself > # and is automatically called by Auth.pm when needed. >-$VERSION = "20.12.00.005"; >+$VERSION = "20.12.00.006"; > > sub version { > return $VERSION; >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 8ef697a7a4..b9c7041570 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -47,6 +47,8 @@ use MARC::File::XML ( BinaryEncoding => 'utf8' ); > use File::Path qw[remove_tree]; # perl core module > use File::Slurp; > >+use Try::Tiny; >+ > # FIXME - The user might be installing a new database, so can't rely > # on /etc/koha.conf anyway. > >@@ -23451,8 +23453,38 @@ if( CheckVersion( $DBversion ) ) { > > $DBversion = '20.12.00.005'; > if( CheckVersion( $DBversion ) ) { >- $dbh->do(q{UPDATE systempreferences set variable="OPACLanguages" WHERE variable="opaclanguages"}); >- NewVersion( $DBversion, 27491, "Rename system preference 'opaclanguages' to 'OPACLanguages'"); >+ execute_entry( >+ $DBversion, 27491, "Rename system preference 'opaclanguages' to 'OPACLanguages'", >+ sub { >+ $dbh->do( >+ q{UPDATE systempreferences set variable="OPACLanguages" WHERE variable="opaclanguages"} >+ ); >+ } >+ ); >+} >+ >+$DBversion = '20.12.00.006'; >+if( CheckVersion( $DBversion ) ) { >+ execute_entry( $DBversion, 12345, "Testing failure", >+ sub { >+ $dbh->do( >+ q{ALTER TABLE foo} >+ ); >+ } >+ ); >+} >+ >+ >+sub execute_entry { >+ my ( $DBversion, $bug_number, $description, $sub ) = @_; >+ >+ try { >+ Koha::Database->schema->txn_do($sub); >+ } catch { >+ die sprintf "Something wrong happened during %s (%s):\n%s", $DBversion, $description, $_; >+ }; >+ >+ NewVersion( $DBversion, $bug_number, $description ); > } > > # SEE bug 13068 >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt >index 685fd7f116..370c1646b5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt >@@ -249,7 +249,7 @@ > [% IF ( updatestructure ) %] > <h2>Updating database structure</h2> > [% IF ( has_update_succeeds ) %] >- <p>Update report :</p> >+ <p>Update report:</p> > <ul> > [% FOREACH l IN update_report %] > [% SET line = l.line %] >-- >2.20.1
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 25078
:
102521
|
116032
|
116033
|
116034
|
116208
|
116209
|
117084
|
121909
|
121910
|
121911
|
121982
|
121983
|
121984
|
122208
|
122322
|
122323
|
122324
|
122325
|
122326
|
122329
|
122665
|
122666
|
122667
|
122668
|
122669
|
122670
|
122671
|
122679
|
122680
|
122875
|
123356
|
123357
|
123358
|
123359
|
123360
|
123361
|
123362
|
123363
|
123364
|
123365
|
123366
|
123367
|
123850
|
123851
|
123853
|
123937
|
124269