diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-06-04 00:21:24 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-06-04 00:21:24 -0700 |
commit | 679854b8bbc65d112071111bbd7f34a6a481fb30 (patch) | |
tree | dda0862fdf7853f4f61e4cf155c8bbc93768c994 /rt/lib/RT.pm | |
parent | 9b328d940af56b9924a342192ebb0790478fa705 (diff) |
RT 4.0.13
Diffstat (limited to 'rt/lib/RT.pm')
-rw-r--r-- | rt/lib/RT.pm | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/rt/lib/RT.pm b/rt/lib/RT.pm index 4372a564d..da60ef77d 100644 --- a/rt/lib/RT.pm +++ b/rt/lib/RT.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -83,12 +83,56 @@ RT - Request Tracker =head1 SYNOPSIS -A fully featured request tracker package +A fully featured request tracker package. + +This documentation describes the point-of-entry for RT's Perl API. To learn +more about what RT is and what it can do for you, visit +L<https://bestpractical.com/rt>. =head1 DESCRIPTION =head2 INITIALIZATION +If you're using RT's Perl libraries, you need to initialize RT before using any +of the modules. + +You have the option of handling the timing of config loading and the actual +init sequence yourself with: + + use RT; + BEGIN { + RT->LoadConfig; + RT->Init; + } + +or you can let RT do it all: + + use RT -init; + +This second method is particular useful when writing one-liners to interact with RT: + + perl -MRT=-init -e '...' + +The first method is necessary if you need to delay or conditionalize +initialization or if you want to fiddle with C<< RT->Config >> between loading +the config files and initializing the RT environment. + +=cut + +{ + my $DID_IMPORT_INIT; + sub import { + my $class = shift; + my $action = shift || ''; + + if ($action eq "-init" and not $DID_IMPORT_INIT) { + $class->LoadConfig; + $class->Init; + $DID_IMPORT_INIT = 1; + } + } +} + =head2 LoadConfig Load RT's config file. First, the site configuration file @@ -316,6 +360,16 @@ sub InitLogging { InitSignalHandlers(%arg); } +{ # Work around bug in Log::Dispatch < 2.30, wherein the short forms + # of ->warn, ->err, and ->crit do not usefully propagate out, unlike + # ->warning, ->error, and ->critical + package Log::Dispatch; + no warnings 'redefine'; + sub warn { shift->warning(@_) } + sub err { shift->error(@_) } + sub crit { shift->critical(@_) } +} + sub InitSignalHandlers { my %arg = @_; @@ -336,6 +390,11 @@ sub InitSignalHandlers { unshift @_, $RT::Logger, qw(level warning message); goto &Log::Dispatch::log; } + # Return value is used only by RT::Test to filter warnings from + # reaching the Test::NoWarnings catcher. If Log::Dispatch::log() ever + # starts returning 'IGNORE', we'll need to switch to something more + # clever. I don't expect that to happen. + return 'IGNORE'; }; #When we call die, trap it and log->crit with the value of the die. |