https://bugzilla.wikimedia.org/show_bug.cgi?id=34819

       Web browser: ---
             Bug #: 34819
           Summary: [MySQL] Possibility for confusing error messages upon
                    opening connection, while background connection is
                    open
           Product: MediaWiki
           Version: 1.20-svn
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: trivial
          Priority: Unprioritized
         Component: Database
        AssignedTo: wikibugs-l@lists.wikimedia.org
        ReportedBy: christ...@quelltextlich.at
    Classification: Unclassified
   Mobile Platform: ---


Created attachment 10134
  --> https://bugzilla.wikimedia.org/attachment.cgi?id=10134
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.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to