Correct MySQL connection error messages
When creating a DatabaseMysql object "dbB" (whose connection fails), while in the background another MySQL connection's previous action resulted in an error, dbB's creation fails with the background connection's error message.
Consider
------8<---Begin---
$dbA=new DatabaseMysql($wgDBserver,$wgDBuser,$wgDBpassword,$wgDBname);
$dbA->selectDB( "non_existing_database" );
wfDebug( "----------------------------\n" );
$wgDBuser = $wgDBuser."someText";
$dbB = wfGetDB( DB_MASTER );
------8<---End---
Connection for $dbA succeeds. Then a non existing database is selected.
Connection for $dbB fails, as the credentials are wrong on purpose.
The log messages for the $dbB connection failure however show:
------8<---Begin---
DB connection error
Server: localhost, User: wikisvnsomeText, Password: wik..., error: Access denied for user 'wikisvn'@'localhost' to database 'non_existing_database'
------8<---End---
Note the part /after/ the "error:".
Same for the DB log:
------8<---Begin---
Wed Feb 29 23:11:13 UTC 2012 spencer wikisvn Error connecting to localhost: Access denied for user 'wikisvn'@'localhost' to database 'non_existing_database' (localhost)
------8<---End---
The attached patch uses mysql_error only as fallback and produces the following log:
------8<---Begin---
DB connection error
Server: localhost, User: wikisvnsomeText, Password: wik..., error: Access denied for user 'wikisvnsomeText'@'localhost' (using password: YES)
------8<---End---
and the following DB log:
------8<---Begin---
Wed Feb 29 23:14:01 UTC 2012 spencer wikisvn Error connecting to localhost: Access denied for user 'wikisvnsomeText'@'localhost' (using password: YES)
------8<---End---
Both, log and DB log, show the expected error message after applying the patch.
Version: 1.20.x
Severity: trivial
Attached: