Peter Adams wrote:
Hi all -
I'm writing an analytics package for MediaWiki and am running into an issue where even though my extension creates a separate mysql connection, MW is catching the DB errors and throwing up its stack trace.
I'm running php 4.4.2 and MW 1.6.3.
It appears that MW is trying to use the mysql connection that my extension has established. a quick look at the MW database.php suggests that this might be an optimization.
Could anyone provide some guidance on how to best avoid this if you are writing an extension that needs to make a mysql connection?
You can create a database connection with new Database(...). This creates a new connection, unless you have DBO_PERSISTENT enabled which you almost certainly don't. Throwing an exception is the standard way to report a query error, if this is a problem for you then you can use $database->ignoreErrors(true). It's probably better though if you just catch the exception, the ignore errors mode isn't very well tested. You can suppress connection errors by passing 1 for the $failFunction parameter of the Database constructor.
-- Tim Starling