Bugzilla – Attachment 50454 Details for
Bug 16306
C4::Context->setCommandlineEnvironment() convenience function
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16306 - C4::Context->setCommandlineEnvironment() convenience function
Bug-16306---C4Context-setCommandlineEnvironment-co.patch (text/plain), 1.47 KB, created by
Olli-Antti Kivilahti
on 2016-04-20 09:26:18 UTC
(
hide
)
Description:
Bug 16306 - C4::Context->setCommandlineEnvironment() convenience function
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2016-04-20 09:26:18 UTC
Size:
1.47 KB
patch
obsolete
>From e5d8b25cb6497423d7a17d518f93af38950871fe Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Wed, 20 Apr 2016 12:25:19 +0300 >Subject: [PATCH] Bug 16306 - C4::Context->setCommandlineEnvironment() > convenience function > >There is no unified way to set the environment for commandline scripts, >even if the C4::Context->interface('commandline') explicitly allows setting >the cli interface. > >Also a default user environment must be set. > >This function wraps the complexity of environment setting in the command line. > >Usage: > >use C4::Context; >BEGIN { > C4::Context->setCommandlineEnvironment(); >} >... #Load other dependencies that might depend on the environment > >or just: > >... >use C4::Context; >C4::Context->setCommandlineEnvironment(); >... >--- > C4/Context.pm | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 05d761e..5cb50e5 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -1293,6 +1293,20 @@ sub IsSuperLibrarian { > return ($userenv->{flags}//0) % 2; > } > >+=head2 setCommandlineEnvironment >+ >+Sets the Koha environment for command line scripts. >+ >+=cut >+ >+sub setCommandlineEnvironment { >+ my ($class) = @_; >+ >+ C4::Context->interface('commandline'); #Set interface for logger and friends >+ C4::Context->_new_userenv('commandline'); >+ C4::Context::set_userenv(1,0,0,'commandline',$0, '', '', {}, '', '', ''); >+} >+ > =head2 interface > > Sets the current interface for later retrieval in any Perl module >-- >1.9.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 16306
:
50454
|
50501
|
64965