Bugzilla – Attachment 6105 Details for
Bug 6877
test for Libravatar::URL can cause scripts to abort
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6877 - use is executed and errors at compile time
Bug-6877---use-is-executed-and-errors-at-compile-t.patch (text/plain), 2.08 KB, created by
Chris Cormack
on 2011-10-28 20:11:27 UTC
(
hide
)
Description:
Bug 6877 - use is executed and errors at compile time
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2011-10-28 20:11:27 UTC
Size:
2.08 KB
patch
obsolete
>From bd0b83b12f50c67a9d3e902a64e476d85d46cbbe Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Sat, 17 Sep 2011 12:45:09 +0100 >Subject: [PATCH] Bug 6877 - use is executed and errors at compile time > >Although use is being called in an eval it will still be executed >at compile time so that an error can cause the script to abort before >the eval is executed. The eval expression syntax is not checked >so eval block should be preferred. >Use require/import which execute at runtime which is the intention >here. > >Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> >--- > opac/opac-detail.pl | 11 ++++++++--- > opac/opac-showreviews.pl | 11 ++++++++--- > 2 files changed, 16 insertions(+), 6 deletions(-) > >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index d3c7e2a..578f98e 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -603,9 +603,14 @@ $template->param( > ); > > my $libravatar_enabled = 0; >-eval 'use Libravatar::URL'; >-if (!$@ and C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) { >- $libravatar_enabled = 1; >+if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) { >+ eval { >+ require Libravatar::URL; >+ Libravatar::URL->import(); >+ }; >+ if (!$@ ) { >+ $libravatar_enabled = 1; >+ } > } > > my $reviews = getreviews( $biblionumber, 1 ); >diff --git a/opac/opac-showreviews.pl b/opac/opac-showreviews.pl >index 3a74270..24ac312 100755 >--- a/opac/opac-showreviews.pl >+++ b/opac/opac-showreviews.pl >@@ -66,9 +66,14 @@ if($format eq "rss"){ > } > > my $libravatar_enabled = 0; >-eval 'use Libravatar::URL'; >-if (!$@ and C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) { >- $libravatar_enabled = 1; >+if ( C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) { >+ eval { >+ require Libravatar::URL; >+ Libravatar::URL->import(); >+ }; >+ if ( !$@ ) { >+ $libravatar_enabled = 1; >+ } > } > > my $reviews = getallreviews(1,$offset,$results_per_page); >-- >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 6877
:
5450
|
5568
| 6105