Bugzilla – Attachment 52132 Details for
Bug 16685
Use eval instead of do for .perl atomicupdates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16685 - Use eval instead of do for .perl atomicupdates
Bug-16685---Use-eval-instead-of-do-for-perl-atomic.patch (text/plain), 1.83 KB, created by
Kyle M Hall (khall)
on 2016-06-07 14:11:58 UTC
(
hide
)
Description:
Bug 16685 - Use eval instead of do for .perl atomicupdates
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-06-07 14:11:58 UTC
Size:
1.83 KB
patch
obsolete
>From 56b137268bf7c353236631e4e603ef265f976120 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 7 Jun 2016 14:07:19 +0000 >Subject: [PATCH] Bug 16685 - Use eval instead of do for .perl atomicupdates > >If we use eval instead of do for our .perl atomic update files, it will >allow developers to put in the exact code that should go into >updatedatabase.pl. The problem with do is that none of the variables >defined in updatadatabase.pl are available, whereas with eval they are. > >Test Plan: >1) Apply this patch >2) Create a .perl file in atomicupdates with the following in it: >say "DBversion: $DBversion"; >3) Run updatadatabase.pl >4) Note the output >5) Add a syntax error to your atomic update >6) Run updatedatabase.pl >7) Note the error is displayed >--- > installer/data/mysql/updatedatabase.pl | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 657ba4e..6934c0a 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -30,6 +30,8 @@ > use strict; > use warnings; > >+use feature 'say'; >+ > # CPAN modules > use DBI; > use Getopt::Long; >@@ -45,6 +47,7 @@ use MARC::File::XML ( BinaryEncoding => 'utf8' ); > > use File::Path qw[remove_tree]; # perl core module > use File::Spec; >+use File::Slurp; > > # FIXME - The user might be installing a new database, so can't rely > # on /etc/koha.conf anyway. >@@ -12628,7 +12631,9 @@ foreach my $file ( sort readdir $dirh ) { > my $installer = C4::Installer->new(); > my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1; > } elsif ( $file =~ /\.perl$/ ) { >- do $update_dir . $file; >+ my $code = read_file( $update_dir . $file ); >+ eval $code; >+ say "Atomic update generated errors: $@" if $@; > } > } > >-- >2.1.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 16685
:
52132
|
52901
|
52902
|
54540
|
54541
|
54729
|
54730
|
54758
|
54759
|
56219