Bugzilla – Attachment 54729 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]
[SIGNED-OFF] Bug 16685 - Use eval instead of do for .perl atomicupdates
SIGNED-OFF-Bug-16685---Use-eval-instead-of-do-for-.patch (text/plain), 1.90 KB, created by
Aleisha Amohia
on 2016-08-23 00:33:29 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 16685 - Use eval instead of do for .perl atomicupdates
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2016-08-23 00:33:29 UTC
Size:
1.90 KB
patch
obsolete
>From 70408c60fd74aafd7015c8eedd7ba007e48832bd 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] [SIGNED-OFF] 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 > >Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com> >--- > 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 6697919..5585b89 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. >@@ -12845,7 +12848,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