[dev] bug in DB? horde 2.1 config parameter ignored in specific case
Vasilios Hoffman
vhoffman01@wesleyan.edu
Fri, 23 Aug 2002 16:59:43 -0400 (EDT)
(oops forgot to subscribe to dev@lists.horde.org, here's the resend):
Using Horde 2.1 w/ php 4.2.2 and the DB module that came with 4.2.2:
DB.php,v 1.86.2.2 2002/04/09 19:04:02
mysql.php,v 1.89.2.1 2002/04/09 19:04:14
If you specify a mysql preference backend on localhost with an alternate
port, it defaults to the standard mysql port (3306) and completely ignores
your chosen port.
If you don't use localhost (even if foo.bar resolves/is localhost), it
does use the port you specify, as it should.
for example (from config/horde.php):
$conf['prefs']['params']['phptype'] = 'mysql';
$conf['prefs']['params']['hostspec'] = 'localhost';
$conf['prefs']['params']['username'] = 'user';
$conf['prefs']['params']['password'] = 'pass';
$conf['prefs']['params']['database'] = 'horde';
$conf['prefs']['params']['table'] = 'horde_prefs';
$conf['prefs']['params']['port'] = '3406';
connects to port 3306 on localhost, as does:
$conf['prefs']['params']['phptype'] = 'mysql';
$conf['prefs']['params']['hostspec'] = 'localhost:3406';
$conf['prefs']['params']['username'] = 'user';
$conf['prefs']['params']['password'] = 'pass';
$conf['prefs']['params']['database'] = 'horde';
$conf['prefs']['params']['table'] = 'horde_prefs';
yet, if foo.bar resolves to localhost, this works fine:
$conf['prefs']['params']['phptype'] = 'mysql';
$conf['prefs']['params']['hostspec'] = 'foo.bar';
$conf['prefs']['params']['username'] = 'user';
$conf['prefs']['params']['password'] = 'pass';
$conf['prefs']['params']['database'] = 'horde';
$conf['prefs']['params']['table'] = 'horde_prefs';
$conf['prefs']['params']['port'] = '3406';
figuring this out was a painful annoyance, I don't know php but it reads
close enough to perl and the other languages I know. I was fairly
certain one of the two methods should work, and when I tried foo.bar
(well, it wasn't foo.bar) it worked like I expected, but localhost did
not give the same behavior.
I'm guessing it's a bug. I added:
if (!isset($this->params['port'])) {
Horde::fatal(new PEAR_Error(_("Required 'port' not specified in
preferences configuration.")), __FILE__, __LINE__);
}
as a hack to see if the port option was being carried along, and it was.
so localhost and port were making it to (the next line):
/* Connect to the SQL server using the supplied parameters. */
include_once 'DB.php'
$this->db = &DB::connect($this->params, true);
So I really think it's a DB issue, which is why I'm CC'ing the DB
maintainers (sorry for the spam if I'm wrong!).
Cheers,
-V
Vasilios Hoffman
Junior Unix Administrator
Wesleyan University
voice (860) 685-3142
fax (860) 685-2401