Bug 367836: Let the shadowdb connection have its own username and password

r=bear
This commit is contained in:
justdave%bugzilla.org 2007-02-04 04:09:22 +00:00
parent 0a01963833
commit 84cc24b8de
2 changed files with 24 additions and 7 deletions

View File

@ -136,6 +136,11 @@ DefParam("cvsadmin",
"t",
'%maintainer%');
DefParam("dbiparam",
"The first parameter to pass to the DBI->connect() method.<br>Example: <code>DBI:mysql:host=localhost;database=bonsai</code>",
"t",
"DBI:mysql:database=bonsai;");
DefParam("mysqluser",
"The username of the bonsai database user.",
"t",
@ -146,16 +151,21 @@ DefParam("mysqlpassword",
"p",
"");
DefParam("dbiparam",
"The first parameter to pass to the DBI->connect() method.<br>Example: <code>DBI:mysql:host=localhost;database=bonsai</code>",
"t",
"DBI:mysql:database=bonsai;");
DefParam("shadowdbiparam",
"The first parameter to pass to the DBI->connect() method of a read-only replicated slave database to use for queries, to help with performance on high-traffic systems. If left blank, queries will be made against the primary database and this param will be ignored.<br>Example: <code>DBI:mysql:host=slaveserver;database=bonsai</code>",
"t",
"");
DefParam("shadowmysqluser",
"The username of the bonsai database user for the shadow database.",
"t",
"nobody");
DefParam("shadowmysqlpassword",
"The password of the bonsai database user for the shadow database.",
"p",
"");
DefParam("readonly",
"Are the hook files readonly. (This value gets changed on the fly,
so it is ok to leave the way it is.)",

View File

@ -109,11 +109,18 @@ sub ConnectToDatabase {
my ($dsn);
if (!defined $::readdb) {
$dsn = Param('shadowdbiparam') || Param('dbiparam');
my $dsn = Param('dbiparam');
my $dbuser = Param('mysqluser');
my $dbpass = Param('mysqlpassword');
if (Param('shadowdbiparam')) {
$dsn = Param('shadowdbiparam');
$dbuser = Param('shadowmysqluser');
$dbpass = Param('shadowmysqlpassword');
}
# DBI->trace(1, "/tmp/dbi.out");
$::readdb = DBI->connect($dsn, Param('mysqluser'), Param('mysqlpassword'))
$::readdb = DBI->connect($dsn, $dbuser, $dbpass)
|| die "Can't connect to database server.";
$::db = $::readdb;
}