MyBB Community Forums

Full Version: Bugs with advanced database configuration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've found 3 bugs regarding Advanced Database Configuration:


1. Documentation. Despite stating in inc/config.default.php that Docs for advanced database configuration can be found at https://docs.mybb.com, I've failed to find them. The only documentation that I've found is "https://blog.mybb.com/2008/03/18/mybb-14-admin-cp-the-complete-overview-part-3/" but it is for version 1.4 and definitely not appliсable for 1.8.10.

So, the correct configuration to use 2 database servers (1 for write and 1 for read) for version 1.8.10 is ("inc/config/php"):

$config['database']['type'] = 'mysqli';
$config['database']['database'] = 'mybb';
$config['database']['table_prefix'] = 'mybb_';
      
$config['database']['write']['hostname'] = 'hostname_read_server';
$config['database']['write']['username'] = 'mybbuser';
$config['database']['write']['password'] = 'mybbpassword';

$config['database']['read']['hostname'] = 'hostname_write_server';
$config['database']['read']['username'] = 'mybbuser';
$config['database']['read']['password'] = 'mybbpassword';



2. errors in "inc/db_mysqli.php" - function: connect():

line 193: unset($connections);

The problem is that it deletes all configuration for other Database servers when it has found the configuration for the first one. So it doesn't matter how many Database servers you have defined in config.php it takes only the first one and then deletes info about other database servers. My solution is to use another temporary variable for the following operations so I've changed lines 194,198,201,247 to use $connections_current variable instead of $connection:

194: $connections_current[$type][] = $details;
198: shuffle($connections_current[$type]);
201: foreach($connections_current[$type] as $single_connection)
247: if(!array_key_exists('write', $connections_current))

and commented line 193: //unset($connections);


Maybe there are similar error for other DB engines. I've checked only for MySQL and only for 1 write and 1 read Database server. Probably some additional modifications to connect() function should be made to use several write and/or several read database servers.



3. error in "inc/function.php":

line 226 is: 
$db->query($query);

but should be: 
$db->write_query($query); 

The problem is that line 226 is trying to use query() function to run shutdown queries. But using query() without last parameter ($write_query) means that it would run with default value for that parameter which is 0 and it would run against read database server. But at least some of shutdown queries are queries which contain SQL UPDATE command and that's why they should be run against write database server.
Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/3619

Thanks for contributing to MyBB!

Regards,
The MyBB Group