summaryrefslogtreecommitdiffstats
path: root/Bugzilla.pm
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-05-23 03:11:53 +0200
committermkanat%bugzilla.org <>2006-05-23 03:11:53 +0200
commited1bcec007e5c0103be4ee53fe8d304a1a1d7c73 (patch)
tree2230f47eea060ed8814a4bdbcab49af04ac67105 /Bugzilla.pm
parent164988606e964028ac2639e58556625b111407b4 (diff)
downloadbugzilla-ed1bcec007e5c0103be4ee53fe8d304a1a1d7c73.tar.gz
bugzilla-ed1bcec007e5c0103be4ee53fe8d304a1a1d7c73.tar.xz
Bug 328642: Params should be in Bugzilla->params instead of being a Bugzilla::Config subroutine
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=justdave
Diffstat (limited to 'Bugzilla.pm')
-rw-r--r--Bugzilla.pm38
1 files changed, 36 insertions, 2 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index d72dba70f..349b05f5f 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -28,7 +28,7 @@ use strict;
use Bugzilla::Auth;
use Bugzilla::Auth::Persist::Cookie;
use Bugzilla::CGI;
-use Bugzilla::Config;
+use Bugzilla::Config qw(:DEFAULT :locations);
use Bugzilla::Constants;
use Bugzilla::DB;
use Bugzilla::Template;
@@ -38,6 +38,7 @@ use Bugzilla::Util;
use Bugzilla::Field;
use File::Basename;
+use Safe;
#####################################################################
# Constants
@@ -70,7 +71,7 @@ use constant SHUTDOWNHTML_EXIT_SILENTLY => [
# This code must go here. It cannot go anywhere in Bugzilla::CGI, because
# it uses Template, and that causes various dependency loops.
if (!$^C
- && Param("shutdownhtml")
+ && Bugzilla->params->{"shutdownhtml"}
&& lsearch(SHUTDOWNHTML_EXEMPT, basename($0)) == -1)
{
# Allow non-cgi scripts to exit silently (without displaying any
@@ -128,6 +129,13 @@ sub cgi {
return $_cgi;
}
+my $_params;
+sub params {
+ my $class = shift;
+ $_params ||= _load_param_values();
+ return $_params;
+}
+
my $_user;
sub user {
my $class = shift;
@@ -324,6 +332,26 @@ sub _cleanup {
undef $_dbh;
}
+sub _load_param_values {
+ my %params;
+ if (-e "$datadir/params") {
+ # Note that checksetup.pl sets file permissions on '$datadir/params'
+
+ # Using Safe mode is _not_ a guarantee of safety if someone does
+ # manage to write to the file. However, it won't hurt...
+ # See bug 165144 for not needing to eval this at all
+ my $s = new Safe;
+
+ $s->rdo("$datadir/params");
+ die "Error reading $datadir/params: $!" if $!;
+ die "Error evaluating $datadir/params: $@" if $@;
+
+ # Now read the param back out from the sandbox
+ %params = %{$s->varglob('param')};
+ }
+ return \%params;
+}
+
sub END {
_cleanup();
}
@@ -473,4 +501,10 @@ Switch from using the main database to using the shadow database.
Change the database object to refer to the main database.
+=item C<params>
+
+The current Parameters of Bugzilla, as a hashref. If C<data/params>
+does not exist, then we return an empty hashref. If C<data/params>
+is unreadable or is not valid perl, we C<die>.
+
=back