@@ -260,13 +260,27 @@ public function createDatabaseForPackageInstance(&$settings, $websrv) {
260260 $ webserver_config = $ app ->getconf ->get_server_config ($ app ->functions ->intval ($ websrv ['server_id ' ]), 'server ' );
261261 $ mysql_db_remote_ips = $ webserver_config ['ip_address ' ];
262262 } else {
263+ // Changing column lookup from default_dbserver to db_servers
264+ $ client = $ app ->db ->queryOneRecord ("SELECT db_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ? " , $ websrv ['sys_groupid ' ]);
265+ if (is_array ($ client ) && $ client ['db_servers ' ] > 0 && $ client ['db_servers ' ] != $ websrv ['server_id ' ]) {
266+ $ mysql_db_server_id = $ app ->functions ->intval ($ client ['db_servers ' ]);
267+ $ dbserver_config = $ web_config = $ app ->getconf ->get_server_config ($ app ->functions ->intval ($ mysql_db_server_id ), 'server ' );
268+ $ settings ['main_database_host ' ] = $ dbserver_config ['ip_address ' ];
269+ $ mysql_db_remote_access = 'y ' ;
270+ $ webserver_config = $ app ->getconf ->get_server_config ($ app ->functions ->intval ($ websrv ['server_id ' ]), 'server ' );
271+ $ mysql_db_remote_ips = $ webserver_config ['ip_address ' ];
272+ } else { // Really nothing to do if reach this point :)
273+ return false ;
274+ }
275+
276+
263277 /* I left this in place for a fallback that should NEVER! happen.
264278 * if we reach this point it means that there is NO default db server for the client
265279 * AND the webserver has NO db service enabled.
266280 * We have to abort the aps installation here... so I added a return false
267281 * although this does not present any error message to the user.
268282 */
269- return false ;
283+ // return false;
270284
271285 /*$mysql_db_server_id = $websrv['server_id'];
272286 $settings['main_database_host'] = 'localhost';
0 commit comments