Bugzilla – Attachment 42918 Details for
Bug 14906
Koha::Logger does not correctly handle instantiation errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 14906: Koha::Logger - handle permission issues
SIGNED-OFF-Bug-14906-KohaLogger---handle-permissio.patch (text/plain), 2.51 KB, created by
Kyle M Hall (khall)
on 2015-09-28 13:42:24 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 14906: Koha::Logger - handle permission issues
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-09-28 13:42:24 UTC
Size:
2.51 KB
patch
obsolete
>From 416c9d318cdedf41a3f7070bb2772fc847e26791 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 28 Sep 2015 10:18:15 +0100 >Subject: [PATCH] [SIGNED-OFF] Bug 14906: Koha::Logger - handle permission issues > >Koha::Logger should log in the regular log files if the paths are not >correctly set (does not exist, no permission to write, etc.). > >Test plan: >Set a path without write permission for the intranet in the log4perl >configuration file. The one for opac should be correct. >Try to write 1 line in the OPAC file. >Without this patch, nothing is logged, and nothing is warned in the >regular Koha log file. >With this patch, the line in the OPAC log file will be appened and the >Koha log file will have a line with a permission issue. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Logger.pm | 5 ++++- > t/Logger.t | 9 +++++++-- > 2 files changed, 11 insertions(+), 3 deletions(-) > >diff --git a/Koha/Logger.pm b/Koha/Logger.pm >index b454100..04eaa02 100644 >--- a/Koha/Logger.pm >+++ b/Koha/Logger.pm >@@ -155,7 +155,10 @@ sub _check_conf { # check logfiles in log4perl config (at initialization) > if ( $l =~ /(OPAC|INTRANET)\.filename\s*=\s*(.*)\s*$/i ) { > > # we only check the two default logfiles, skipping additional ones >- return if !-w $2; >+ unless ( -w $2 ) { >+ carp "Logger configuration error - Wrong permission for file $2"; >+ next; >+ } > push @logs, $1 . ':' . $2; > } > } >diff --git a/t/Logger.t b/t/Logger.t >index cef4ea1..43001c6 100644 >--- a/t/Logger.t >+++ b/t/Logger.t >@@ -26,7 +26,7 @@ use Test::More tests => 1; > use Test::Warn; > > subtest 'Test01 -- Simple tests for Koha::Logger' => sub { >- plan tests => 8; >+ plan tests => 9; > test01(); > }; > >@@ -52,7 +52,12 @@ log4perl.appender.INTRANET.layout.ConversionPattern=[%d] [%p] %m %l %n > HERE > ); > $mContext->mock( 'config', sub { return $conf; } ); >- $logger= Koha::Logger->get({ interface => 'intranet' }); >+ system("chmod 400 $log"); >+ warning_like { $logger = Koha::Logger->get({ interface => 'intranet' }) } >+ qr/permission/, "Koha::Logger should raise a warning if there is a permission issue"; >+ >+ system("chmod 600 $log"); >+ $logger = Koha::Logger->get({ interface => 'intranet' }); > is( exists $logger->{logger}, 1, 'Log4perl config found'); > is( $logger->warn('Message 2'), 1, 'Message 2 returned a value' ); > warning_is { $ret = $logger->catastrophe } >-- >1.7.2.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 14906
:
42904
| 42918