#745 closed defect (bug) (fixed)
When using mysqli extension, db connect fails
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 0.9 | Priority: | high |
| Severity: | major | Version: | 0.8.3 |
| Component: | General - Administration | Keywords: | |
| Cc: |
Description
http://bbpress.org/forums/topic/db-access-problem-in-the-first-installation-step
http://bbpress.org/forums/topic/intergration-will-not-let-me-logon-using-my-wordpress-login
Warning: mysql_get_server_info() [function.mysql-get-server-info]: Access denied for user 'root'@'localhost' (using password: NO) in /bb-includes/db-mysqli.php on line 80
User and Password are supplied, but bbPress tries to connect with root (or equivalent) without a password.
Only effects mysqli connections, not mysql.
Overwrite db-mysqli.php with db.php, and everything works.
Attachments (3)
Change History (17)
#2
@
19 years ago
That call to mysqli_get_server_info() needs to contain the link to the mysqli object.
So perhaps line 80 should be:
if ( !empty($this->charset) && version_compare(mysqli_get_server_info($this->$dbhname), '4.1.0', '>=') )
#3
@
19 years ago
If mysql_get_server_info() is changed to mysqli_get_server_info(), it works fine since it uses the last link opened by mysqli_connect. To be explicit, you could put that parameter there, but if it fails to use the last link object, I think including the parameter explicitly would fail too. The link object is typically optional I think.
#4
@
19 years ago
Interesting, I just read this comment:
http://bbpress.org/forums/topic/db-access-problem-in-the-first-installation-step?replies=10#post-11205
Warning: mysqli_get_server_info() expects exactly 1 parameter, 0 given
http://us.php.net/manual/en/function.mysqli-get-server-info.php
Apparently, mysqli_get_server_info requires the parameter, where mysql_get_server_info does not. So, I believe you're right Sam to require the $this->$dbhname (contradicting what I said earlier.) Apparently when I was testing this, I had added that object first, then tried the mysqli change, so I had already done it, but was going off information I read for mysql_get_server_info.
#5
@
19 years ago
Try 745.diff out. It uses mysqli_ when appropriate. It's a little tricky in upgrade-schema.php since we could be looking at two different DBs, the normal one and the user one.
#6
@
19 years ago
I realized that BB_Query should be using mysql(i)_get_server_info() instead of mysql(i)_get_client_info(), so I decided version info was a useful enough thing to know that it should be in the DB class.
In 745c.diff
$bbdb->db_version( $dbh ) where $dbh can either be a string specifying the table name of a table in the database you're interested in, or a mysql(i)_connect() resource.
I chose table name over DB name for future compatibility with WordPress MU, HyperDB and BackPress.
Thoughts?
#8
@
19 years ago
I tried to apply DiffC to an svn checkout of 0.8.3, but part of it failed:
server:~/bbpress-test > patch -p0 < diffc.patch patching file bb-includes/classes.php patching file bb-includes/db-mysqli.php Hunk #2 FAILED at 79. 1 out of 3 hunks FAILED -- saving rejects to file bb-includes/db-mysqli.php.rej patching file bb-includes/db.php patching file bb-admin/upgrade-schema.php
The content of bb-includes/db-mysqli.php.rej:
***************
*** 77,83 ****
$this->$dbhname = @mysqli_connect( $server->host, $server->user, $server->pass, null, $server->port );
- if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') )
$this->query("SET NAMES '$this->charset'");
$this->select( $server->database, $this->$dbhname );
--- 79,85 ----
$this->$dbhname = @mysqli_connect( $server->host, $server->user, $server->pass, null, $server->port );
+ if ( !empty($this->charset) && version_compare(mysqli_get_server_info($this->$dbhname), '4.1.0', '>=') )
$this->query("SET NAMES '$this->charset'");
$this->select( $server->database, $this->$dbhname );
FYI
#9
@
18 years ago
- Owner set to mdawaffe
- Status changed from new to assigned
WP has a slightly better way of doing this. I'll smoosh them together.
#11
@
18 years ago
Someone want to kick this in PHP 5?
Someone want to kick this using the mysqli extension?
I just posted in the forum:
I think the problem is with <a href="http://trac.bbpress.org/browser/trunk/bb-includes/db-mysqli.php#L80">line 80 in db-mysqli.php</a>:
if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') )
I think mysql_get_server_info() should be mysqli_get_server_info()
As it stands, the error produces a warning and prevents the charset from ever being set. Making that mysqli_get_server_info makes the warnings go away.