summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Attachment/PatchReader.pm16
-rw-r--r--Bugzilla/Config.pm11
-rw-r--r--Bugzilla/DB.pm35
-rw-r--r--Bugzilla/Install/Localconfig.pm19
-rwxr-xr-xtestserver.pl9
5 files changed, 44 insertions, 46 deletions
diff --git a/Bugzilla/Attachment/PatchReader.pm b/Bugzilla/Attachment/PatchReader.pm
index 615ae91b4..8543d6e22 100644
--- a/Bugzilla/Attachment/PatchReader.pm
+++ b/Bugzilla/Attachment/PatchReader.pm
@@ -19,7 +19,6 @@ use strict;
package Bugzilla::Attachment::PatchReader;
-use Bugzilla::Config qw(:localconfig);
use Bugzilla::Error;
@@ -27,6 +26,7 @@ sub process_diff {
my ($attachment, $format, $context) = @_;
my $dbh = Bugzilla->dbh;
my $cgi = Bugzilla->cgi;
+ my $lc = Bugzilla->localconfig;
my $vars = {};
my ($reader, $last_reader) = setup_patch_readers(undef, $context);
@@ -42,7 +42,7 @@ sub process_diff {
}
else {
$vars->{'other_patches'} = [];
- if ($interdiffbin && $diffpath) {
+ if ($lc->{interdiffbin} && $lc->{diffpath}) {
# Get list of attachments on this bug.
# Ignore the current patch, but select the one right before it
# chronologically.
@@ -84,6 +84,7 @@ sub process_diff {
sub process_interdiff {
my ($old_attachment, $new_attachment, $format, $context) = @_;
my $cgi = Bugzilla->cgi;
+ my $lc = Bugzilla->localconfig;
my $vars = {};
# Get old patch data.
@@ -95,8 +96,8 @@ sub process_interdiff {
# Send through interdiff, send output directly to template.
# Must hack path so that interdiff will work.
- $ENV{'PATH'} = $diffpath;
- open my $interdiff_fh, "$interdiffbin $old_filename $new_filename|";
+ $ENV{'PATH'} = $lc->{diffpath};
+ open my $interdiff_fh, "$lc->{interdiffbin} $old_filename $new_filename|";
binmode $interdiff_fh;
my ($reader, $last_reader) = setup_patch_readers("", $context);
@@ -219,7 +220,9 @@ sub setup_patch_readers {
}
# Add in cvs context if we have the necessary info to do it
- if ($context ne 'patch' && $cvsbin && Bugzilla->params->{'cvsroot_get'}) {
+ if ($context ne 'patch' && Bugzilla->localconfig->{cvsbin}
+ && Bugzilla->params->{'cvsroot_get'})
+ {
require PatchReader::AddCVSContext;
$last_reader->sends_data_to(
new PatchReader::AddCVSContext($context, Bugzilla->params->{'cvsroot_get'}));
@@ -246,7 +249,8 @@ sub setup_template_patch_reader {
$vars->{'collapsed'} = $cgi->param('collapsed');
$vars->{'context'} = $context;
- $vars->{'do_context'} = $cvsbin && Bugzilla->params->{'cvsroot_get'} && !$vars->{'newid'};
+ $vars->{'do_context'} = Bugzilla->localconfig->{cvsbin}
+ && Bugzilla->params->{'cvsroot_get'} && !$vars->{'newid'};
# Print everything out.
print $cgi->header(-type => 'text/html',
diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm
index 7db033285..1423c1196 100644
--- a/Bugzilla/Config.pm
+++ b/Bugzilla/Config.pm
@@ -43,18 +43,13 @@ use File::Temp;
%Bugzilla::Config::EXPORT_TAGS =
(
admin => [qw(update_params SetParam write_params)],
- db => [qw($db_driver $db_host $db_port $db_name $db_user $db_pass $db_sock
- $db_check)],
- localconfig => [qw($cvsbin $interdiffbin $diffpath $webservergroup)],
);
-Exporter::export_ok_tags('admin', 'db', 'localconfig');
+Exporter::export_ok_tags('admin');
use vars qw(@param_list);
# INITIALISATION CODE
# Perl throws a warning if we use bz_locations() directly after do.
-our $localconfig = bz_locations()->{'localconfig'};
-do $localconfig;
our %params;
# Load in the param definitions
sub _load_params {
@@ -327,10 +322,6 @@ Bugzilla::Config - Configuration parameters for Bugzilla
SetParam($param, $value);
write_params();
- # Localconfig variables may also be imported
- use Bugzilla::Config qw(:db);
- print "Connecting to $db_name as $db_user with $db_pass\n";
-
=head1 DESCRIPTION
This package contains ways to access Bugzilla configuration parameters.
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index a87c1a606..6bb3b1255 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -35,7 +35,6 @@ use DBI;
# Inherit the DB class from DBI::db.
use base qw(DBI::db);
-use Bugzilla::Config qw(:db);
use Bugzilla::Constants;
use Bugzilla::Install::Requirements;
use Bugzilla::Install::Localconfig;
@@ -81,14 +80,17 @@ sub connect_shadow {
die "Tried to connect to non-existent shadowdb"
unless $params->{'shadowdb'};
- return _connect($db_driver, $params->{"shadowdbhost"},
+ my $lc = Bugzilla->localconfig;
+
+ return _connect($lc->{db_driver}, $params->{"shadowdbhost"},
$params->{'shadowdb'}, $params->{"shadowdbport"},
- $params->{"shadowdbsock"}, $db_user, $db_pass);
+ $params->{"shadowdbsock"}, $lc->{db_user}, $lc->{db_pass});
}
sub connect_main {
- return _connect($db_driver, $db_host, $db_name, $db_port,
- $db_sock, $db_user, $db_pass);
+ my $lc = Bugzilla->localconfig;
+ return _connect($lc->{db_driver}, $lc->{db_host}, $lc->{db_name}, $lc->{db_port},
+ $lc->{db_sock}, $lc->{db_user}, $lc->{db_pass});
}
sub _connect {
@@ -120,10 +122,11 @@ sub _handle_error {
sub bz_check_requirements {
my ($output) = @_;
- my $db = DB_MODULE->{lc($db_driver)};
+ my $lc = Bugzilla->localconfig;
+ my $db = DB_MODULE->{lc($lc->{db_driver})};
# Only certain values are allowed for $db_driver.
if (!defined $db) {
- die "$db_driver is not a valid choice for \$db_driver in"
+ die "$lc->{db_driver} is not a valid choice for \$db_driver in"
. bz_locations()->{'localconfig'};
}
@@ -149,7 +152,7 @@ EOT
# We don't try to connect to the actual database if $db_check is
# disabled.
- unless ($db_check) {
+ unless ($lc->{db_check}) {
print "\n" if $output;
return;
}
@@ -186,6 +189,7 @@ sub bz_create_database {
my $dbh;
# See if we can connect to the actual Bugzilla database.
my $conn_success = eval { $dbh = connect_main(); };
+ my $db_name = Bugzilla->localconfig->{db_name};
if (!$conn_success) {
$dbh = _get_no_db_connection();
@@ -209,12 +213,13 @@ sub bz_create_database {
sub _get_no_db_connection {
my ($sql_server) = @_;
my $dbh;
+ my $lc = Bugzilla->localconfig;
my $conn_success = eval {
- $dbh = _connect($db_driver, $db_host, '', $db_port,
- $db_sock, $db_user, $db_pass);
+ $dbh = _connect($lc->{db_driver}, $lc->{db_host}, '', $lc->{db_port},
+ $lc->{db_sock}, $lc->{db_user}, $lc->{db_pass});
};
if (!$conn_success) {
- my $sql_server = DB_MODULE->{lc($db_driver)}->{name};
+ my $sql_server = DB_MODULE->{lc($lc->{db_driver})}->{name};
# Can't use $dbh->errstr because $dbh is undef.
my $error = $DBI::errstr;
chomp($error);
@@ -230,7 +235,8 @@ sub _get_no_db_connection {
# username, and db_new errors can show up on CGIs.
sub _bz_connect_error_reasons {
my $lc_file = bz_locations()->{'localconfig'};
- my $db = DB_MODULE->{lc($db_driver)};
+ my $lc = Bugzilla->localconfig;
+ my $db = DB_MODULE->{lc($lc->{db_driver})};
my $server = $db->{name};
return <<EOT;
@@ -241,7 +247,7 @@ This might have several reasons:
server configuration or the database access rights. Read the Bugzilla
Guide in the doc directory. The section about database configuration
should help.
-* Your password for the '$db_user' user, specified in \$db_pass, is
+* Your password for the '$lc->{db_user}' user, specified in \$db_pass, is
incorrect, in '$lc_file'.
* There is a subtle problem with Perl, DBI, or $server. Make
sure all settings in '$lc_file' are correct. If all else fails, set
@@ -355,7 +361,8 @@ sub bz_server_version {
sub bz_last_key {
my ($self, $table, $column) = @_;
- return $self->last_insert_id($db_name, undef, $table, $column);
+ return $self->last_insert_id(Bugzilla->localconfig->{db_name}, undef,
+ $table, $column);
}
sub bz_get_field_defs {
diff --git a/Bugzilla/Install/Localconfig.pm b/Bugzilla/Install/Localconfig.pm
index 971c27d02..1f5da3108 100644
--- a/Bugzilla/Install/Localconfig.pm
+++ b/Bugzilla/Install/Localconfig.pm
@@ -10,6 +10,10 @@
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
+# The Initial Developer of the Original Code is Everything Solved.
+# Portions created by Everything Solved are Copyright (C) 2006
+# Everything Solved. All Rights Reserved.
+#
# The Original Code is the Bugzilla Bug Tracking System.
#
# Contributor(s): Max Kanat-Alexander <mkanat@bugzilla.org>
@@ -39,10 +43,7 @@ our @EXPORT_OK = qw(
update_localconfig
);
-# We write this constant as a sub because it has to call other
-# subroutines.
-sub LOCALCONFIG_VARS {
- return (
+use constant LOCALCONFIG_VARS => (
{
name => 'create_htaccess',
default => 1,
@@ -156,7 +157,7 @@ EOT
},
{
name => 'cvsbin',
- default => &_get_default_cvsbin,
+ default => \&_get_default_cvsbin,
desc => <<EOT
# For some optional functions of Bugzilla (such as the pretty-print patch
# viewer), we need the cvs binary to access files and revisions.
@@ -166,7 +167,7 @@ EOT
},
{
name => 'interdiffbin',
- default => &_get_default_interdiffbin,
+ default => \&_get_default_interdiffbin,
desc => <<EOT
# For some optional functions of Bugzilla (such as the pretty-print patch
# viewer), we need the interdiff binary to make diffs between two patches.
@@ -176,14 +177,13 @@ EOT
},
{
name => 'diffpath',
- default => &_get_default_diffpath,
+ default => \&_get_default_diffpath,
desc => <<EOT
# The interdiff feature needs diff, so we have to have that path.
# Please specify the directory name only; do not use trailing slash.
EOT
},
- );
-}
+);
use constant OLD_LOCALCONFIG_VARS => qw(
mysqlpath
@@ -280,6 +280,7 @@ sub update_localconfig {
my $name = $var->{name};
if (!defined $localconfig->{$name}) {
push(@new_vars, $name);
+ $var->{default} = &{$var->{default}} if ref($var->{default}) eq 'CODE';
$localconfig->{$name} = $answer->{$name} || $var->{default};
}
}
diff --git a/testserver.pl b/testserver.pl
index bf818cd0f..9c12b9573 100755
--- a/testserver.pl
+++ b/testserver.pl
@@ -21,14 +21,8 @@
use strict;
use lib ".";
-BEGIN {
- my $envpath = $ENV{'PATH'};
- require Bugzilla;
- $ENV{'PATH'} = $envpath;
-}
-
+use Bugzilla;
use Bugzilla::Constants;
-use Bugzilla::Config qw(:localconfig);
use Socket;
@@ -62,6 +56,7 @@ if ($^O !~ /MSWin32/i) {
# Determine the numeric GID of $webservergroup
my $webgroupnum = 0;
+my $webservergroup = Bugzilla->localconfig->{webservergroup};
if ($webservergroup =~ /^(\d+)$/) {
$webgroupnum = $1;
} else {