Last modified: 2010-05-15 15:33:59 UTC
When an AuthPlugin directly uses mysql_connect to connect to a different DB on the same MySQL server any DB requests by the MediaWiki fail producing the following stack trace: Notice: Only variable references should be returned by reference in /wiki/includes/Namespace.php on line 136 Notice: Only variable references should be returned by reference in /wiki/includes/ObjectCache.php on line 369 Warning: mysql_query(): 63 is not a valid MySQL-Link resource in /wiki/includes/Database.php on line 349 Warning: mysql_query(): 63 is not a valid MySQL-Link resource in /wiki/includes/Database.php on line 349 Warning: mysql_query(): 63 is not a valid MySQL-Link resource in /wiki/includes/Database.php on line 349 Notice: Only variables should be assigned by reference in /wiki/includes/Parser.php on line 1225 Notice: Only variables should be assigned by reference in /wiki/includes/Parser.php on line 1045 Notice: Only variables should be assigned by reference in /wiki/includes/Parser.php on line 1140 Notice: Only variables should be assigned by reference in /wiki/includes/Parser.php on line 2540 Notice: Only variables should be assigned by reference in /wiki/includes/Parser.php on line 796 Warning: mysql_query(): 63 is not a valid MySQL-Link resource in /wiki/includes/Database.php on line 349 Notice: Only variable references should be returned by reference in /wiki/includes/SkinTemplate.php on line 136 Notice: Only variable references should be returned by reference in /wiki/includes/Namespace.php on line 136 Warning: mysql_query(): 63 is not a valid MySQL-Link resource in /wiki/includes/Database.php on line 349 Warning: mysql_query(): 63 is not a valid MySQL-Link resource in /wiki/includes/Database.php on line 349 Warning: mysql_query(): 63 is not a valid MySQL-Link resource in /wiki/includes/Database.php on line 349 Notice: Only variable references should be returned by reference in /wiki/includes/Namespace.php on line 136 Warning: mysql_query(): 63 is not a valid MySQL-Link resource in /wiki/includes/Database.php on line 349 Unable to free MySQL result Backtrace: * GlobalFunctions.php line 524 calls wfbacktrace() * Database.php line 495 calls wfdebugdiebacktrace() * User.php line 594 calls databasemysql::freeresult() * SkinTemplate.php line 254 calls user::getnewtalk() * OutputPage.php line 431 calls skinmonobook::outputpage() * index.php line 223 calls outputpage::output()
Please provide sample code to reproduce.
Created attachment 854 [details] The external AuthPlugin (phpBB Auth for Wiki) This AuthPlugin is a modified version of http://meta.wikimedia.org/wiki/PHPBB/Users_Integration which was modified to work with the phpBB table if it's on a different DB than the Wiki.
I forgot to mention installiation due to changes in my code: Add the following lines somewhere in the LocalSettings.php for the Wiki: // PHPBB User Database Plugin. (Requires MySQL Database) require_once './extensions/Auth_phpBB.php'; $wgPHPBB_WikiGroupName = 'Entwickler (Wiki)'; // Name of your phpBB group users need to be a member of to use the wiki. (i.e. wiki) $wgPHPBB_DBserver = $wgDBserver; // Name of your phpBB DB Server $wgPHPBB_DBname = "usr_web28_2"; // Name of your phpBB DB Name (different from the Wiki's one) $wgPHPBB_DBuser = $wgDBuser; // Name of your phpBB DB User $wgPHPBB_DBpassword = $wgDBpassword; // Name of your phpBB DB Password $wgPHPBB_UserTB = 'phpbb_users'; // Name of your phpBB user table. (i.e. phpbb_users) $wgPHPBB_GroupsTB = 'phpbb_groups'; // Name of your phpBB groups table. (i.e. phpbb_groups) $wgPHPBB_User_GroupTB = 'phpbb_user_group'; // Name of your phpBB user_group table. (i.e. phpbb_user_group) $wgAuth = new Auth_PHPBB(); // Auth_PHPBB Plugin.
If your server, username, and password are the same for the PHPBB connection, mysql_connect() will by default reuse an existing open connection -- which will belong to the wiki. When you do mysql_select_db() on that connection to use a different database, that will leave the wiki's connection fubar'd. Either pass the new_link parameter to mysql_connect(), or mysql_select_db () it back when you're done. See: http://www.php.net/mysql_connect
Well, at first a big THX for this information. But wouldn't it be more intuitive to change the behaviour of the database object that way that the selectdb is auto-exec bevore each query? But well, I'll include that 4th param to fix it as suggested.
That would be an unnecessary burden on performance, and very error-prone where multi-database stuff actually is supposed to happen. It's better to not corrupt your database connections in the first place! :)