summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-04-27 21:01:24 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-04-27 21:01:24 +0200
commit68af4d3c22ce1cb25793af5fb9f422bbb6ebe80e (patch)
tree1283a8a34de7cdbf7675aa05514e3289602c34d7 /Bugzilla/DB
parentb7fbcf61cf1267564edaf343833fa15f1a806430 (diff)
downloadbugzilla-68af4d3c22ce1cb25793af5fb9f422bbb6ebe80e.tar.gz
bugzilla-68af4d3c22ce1cb25793af5fb9f422bbb6ebe80e.tar.xz
Bug 561322: Make Bugzilla::DB::_connect and related functions take their
parameters as a hashref, to improve the API and to avoid exposing the database password on error. r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'Bugzilla/DB')
-rw-r--r--Bugzilla/DB/Mysql.pm7
-rw-r--r--Bugzilla/DB/Oracle.pm7
-rw-r--r--Bugzilla/DB/Pg.pm7
3 files changed, 15 insertions, 6 deletions
diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm
index 297cf5758..13069a78a 100644
--- a/Bugzilla/DB/Mysql.pm
+++ b/Bugzilla/DB/Mysql.pm
@@ -61,7 +61,9 @@ use constant MAX_COMMENTS => 50;
use base qw(Bugzilla::DB);
sub new {
- my ($class, $user, $pass, $host, $dbname, $port, $sock) = @_;
+ my ($class, $params) = @_;
+ my ($user, $pass, $host, $dbname, $port, $sock) =
+ @$params{qw(db_user db_pass db_host db_name db_port db_sock)};
# construct the DSN from the parameters we got
my $dsn = "dbi:mysql:host=$host;database=$dbname";
@@ -74,7 +76,8 @@ sub new {
mysql_auto_reconnect => 1,
);
- my $self = $class->db_new($dsn, $user, $pass, \%attrs);
+ my $self = $class->db_new({ dsn => $dsn, user => $user,
+ pass => $pass, attrs => \%attrs });
# This makes sure that if the tables are encoded as UTF-8, we
# return their data correctly.
diff --git a/Bugzilla/DB/Oracle.pm b/Bugzilla/DB/Oracle.pm
index 5dd127882..6fa7a9869 100644
--- a/Bugzilla/DB/Oracle.pm
+++ b/Bugzilla/DB/Oracle.pm
@@ -54,7 +54,9 @@ use constant ISOLATION_LEVEL => 'READ COMMITTED';
use constant BLOB_TYPE => { ora_type => ORA_BLOB };
sub new {
- my ($class, $user, $pass, $host, $dbname, $port) = @_;
+ my ($class, $params) = @_;
+ my ($user, $pass, $host, $dbname, $port) =
+ @$params{qw(db_user db_pass db_host db_name db_port)};
# You can never connect to Oracle without a DB name,
# and there is no default DB.
@@ -70,7 +72,8 @@ sub new {
LongReadLen => ( Bugzilla->params->{'maxattachmentsize'}
|| 1000 ) * 1024,
};
- my $self = $class->db_new($dsn, $user, $pass, $attrs);
+ my $self = $class->db_new({ dsn => $dsn, user => $user,
+ pass => $pass, attrs => $attrs });
# Needed by TheSchwartz
$self->{private_bz_dsn} = $dsn;
diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm
index b31d186bb..c85c1d710 100644
--- a/Bugzilla/DB/Pg.pm
+++ b/Bugzilla/DB/Pg.pm
@@ -52,7 +52,9 @@ use base qw(Bugzilla::DB);
use constant BLOB_TYPE => { pg_type => DBD::Pg::PG_BYTEA };
sub new {
- my ($class, $user, $pass, $host, $dbname, $port) = @_;
+ my ($class, $params) = @_;
+ my ($user, $pass, $host, $dbname, $port) =
+ @$params{qw(db_user db_pass db_host db_name db_port)};
# The default database name for PostgreSQL. We have
# to connect to SOME database, even if we have
@@ -70,7 +72,8 @@ sub new {
my $attrs = { pg_enable_utf8 => Bugzilla->params->{'utf8'} };
- my $self = $class->db_new($dsn, $user, $pass, $attrs);
+ my $self = $class->db_new({ dsn => $dsn, user => $user,
+ pass => $pass, attrs => $attrs });
# all class local variables stored in DBI derived class needs to have
# a prefix 'private_'. See DBI documentation.