silently ignore "misconfigured" slaves #145

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+12 −1
Diff settings

Always

Just for now

@@ -104,8 +104,19 @@ protected function dbalLoad(array $config, ContainerBuilder $container)
$c = array();
foreach ($config['connections'] as $name => $conf) {
$c['datasources'][$name]['adapter'] = $conf['driver'];
+
if (!empty($conf['slaves'])) {
- $c['datasources'][$name]['slaves']['connection'] = $conf['slaves'];
+ // silently ignore misconfigured slaves
+ // this lets us have slaves in prod but not in dev environments by only altering parameters.inc
+ foreach ($conf['slaves'] as $slaveKey => $slaveData) {
+ if (empty($slaveData['user']) || empty($slaveData['dsn'])) {
+ unset($conf['slaves'][$slaveKey]);
+ }
+ }
+
+ if (!empty($conf['slaves'])) {
+ $c['datasources'][$name]['slaves']['connection'] = $conf['slaves'];
+ }
}
foreach (array('dsn', 'user', 'password', 'classname', 'options', 'attributes', 'settings') as $att) {